Part Number Hot Search : 
CXA1929M ON1144 2SB648 MM3094F WP513EDT SMF24CT1 82C54 ZPSD303R
Product Description
Full Text Search
 

To Download 3850 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  regarding the change of names mentioned in the document, such as mitsubishi electric and mitsubishi xx, to renesas technology corp. the semiconductor operations of hitachi and mitsubishi electric were transferred to renesas technology corporation on april 1st 2003. these operations include microcomputer, logic, analog and discrete devices, and memory chips other than drams (flash memory, srams etc.) accordingly, although mitsubishi electric, mitsubishi electric corporation, mitsubishi semiconductors, and other mitsubishi brand names are mentioned in the document, these names have in fact all been changed to renesas technology corp. thank you for your understanding. except for our corporate trademark, logo and corporate statement, no changes whatsoever have been made to the contents of the document, and these changes do not constitute any alteration to the contents of the document itself. note : mitsubishi electric will continue the business operations of high frequency & optical devices and power devices. renesas technology corp. customer support dept. april 1, 2003 to all our customers
mitsubishi 8-bit single-chip microcomputer 740 family / 38000 series 3850/3851 group users manual
keep safety first in your circuit designs ! l mitsubishi electric corporation puts the maximum effort into making semiconductor products better and more reliable, but there is always the possibility that trouble may occur with them. trouble with semiconductors may lead to personal injury, fire or property damage. remember to give due consideration to safety when making your circuit designs, with appropriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of non-flammable material or (iii) prevention against any malfunction or mishap. notes regarding these materials l these materials are intended as a reference to assist our customers in the selection of the mitsubishi semiconductor product best suited to the customers application; they do not convey any license under any intellectual property rights, or any other rights, belonging to mitsubishi electric corporation or a third party. l mitsubishi electric corporation assumes no responsibility for any damage, or infringement of any third-partys rights, originating in the use of any product data, diagrams, charts or circuit application examples contained in these materials. l all information contained in these materials, including product data, diagrams and charts, represent information on products at the time of publication of these materials, and are subject to change by mitsubishi electric corporation without notice due to product improvements or other reasons. it is therefore recommended that customers contact mitsubishi electric corporation or an authorized mitsubishi semiconductor product distributor for the latest product information before purchasing a product listed herein. l mitsubishi electric corporation semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake. please contact mitsubishi electric corporation or an authorized mitsubishi semiconductor product distributor when considering the use of a product contained herein for any specific purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use. l the prior written approval of mitsubishi electric corporation is necessary to reprint or reproduce in whole or in part these materials. l if these products or technologies are subject to the japanese export control restrictions, they must be exported under a license from the japanese government and cannot be imported into a country other than the approved destination. any diversion or reexport contrary to the export control laws and regulations of japan and/or the country of destination is prohibited. l please contact mitsubishi electric corporation or an authorized mitsubishi semiconductor product distributor for further details on these materials or the products contained therein.
rev. rev. no. date 1.0 first edition 981021 revision description list 3850/3851 group users manual (1/1) revision description
preface this users manual describes mitsubishis cmos 8- bit microcomputers 3851 group and 3850 group. after reading this manual, the user should have a through knowledge of their functions and features, and should be able to fully utilize the product. the manual starts with specifications and ends with application examples. the difference between the 3851 group and 3850 group is the i 2 c-bus built-in or not. the 3850 group does not have the built-in i 2 c-bus. accordingly, use this users manual with care, considering the difference between the 3851 group and 3850 group. this users manual mainly explains the 3851 group. the difference is explained in the section functional description supplement of chapter 1 . for details of software, refer to the 740 series software manual. for details of development support tools, refer to the data book or the data sheet of development support tools for 740 family.
before using this manual this users manual consists of the following three chapters. refer to the chapter appropriate to your conditions, such as hardware design or software development. chapter 3 also includes necessary information for systems development. you must refer to that chapter. 1. organization l chapter 1 hardware this chapter describes features of the microcomputer and operation of each peripheral function. l chapter 2 application this chapter describes usage and application examples of peripheral functions, based mainly on setting examples of relevant registers. l chapter 3 appendix this chapter includes necessary information for systems development using the microcomputer, such as the electrical characteristics, the list of registers, the mask rom confirmation form (for mask rom version), the rom programming confirmation form (for one time prom version), and the mark specification form which are to be submitted when ordering. 2. structure of register the figure of each register structure describes its functions, contents at reset, and attributes as follows : note 2 : bit attributes......... the attributes of control register bits are classified into 3 bytes : read-only, write- only and read and write. in the figure, these attributes are represented as follows : : bit in which nothing is arranged 0 1 : name function at reset rw b 0 1 2 3 4 0 0 0 0 0 5 5 5 6 7 1 b0 b1 b2 b3 b4 b5 b6 b7 contents immediately after reset release bit attributes (note 1) processor mode bits stack page selection bit nothing arranged for these bits. these are write disabled bits. when these bits are read out, the contents are ?. fix this bit to ?. main clock (x in -x out ) stop bit internal system clock selection bit 0 0 : single-chip mode 1 0 : 1 1 : not available b1 b0 0 : 0 page 1 : 1 page 0 : operating 1 : stopped 0 : x in -x out selected 1 : x cin -x cout selected : bit that is not used for control of the corresponding function 0 note 1 :. contents immediately after reset release 0....... ??at reset release 1....... ??at reset release ?....... undefined at reset release ] .......contents determined by option at reset release r....... read ...... read enabled 5 .......read disabled w......write ..... write enabled 5 ...... write disabled ] .......??write (note 2) cpu mode register (cpum) [address : 3b 16 ] bits ] ]
i 3850/3851 group users manual table of contents table of contents chapter 1 hardware description ............................................................................................................................... . 1-2 features ............................................................................................................................... ....... 1-2 application ............................................................................................................................... . 1-2 pin configuration (top view) ........................................................................................... 1-2 functional block .................................................................................................................. 1-3 pin description ........................................................................................................................ 1-4 part numbering ....................................................................................................................... 1-5 group expansion .................................................................................................................... 1-6 memory type ............................................................................................................................ 1-6 memory size ............................................................................................................................. 1- 6 packages ............................................................................................................................... .... 1-6 functional description ...................................................................................................... 1-7 central processing unit (cpu) .............................................................................................. 1-7 memory ............................................................................................................................... .. 1-11 i/o ports .............................................................................................................................. 1 -13 interrupts .......................................................................................................................... 1-16 timers ............................................................................................................................... .... 1-19 serial i/o .............................................................................................................................. 1 -21 multi-master i 2 c-bus interface ............................................................................... 1-25 pulse width modulation (pwm) ................................................................................ 1-36 a-d converter .................................................................................................................. 1-38 watchdog timer .............................................................................................................. 1-39 reset circuit .................................................................................................................... 1-40 clock generating circuit ......................................................................................... 1-42 notes on programming ..................................................................................................... 1-45 processor status register .................................................................................................... 1-45 interrupts ............................................................................................................................... .. 1-45 decimal calculations .............................................................................................................. 1-45 timers ............................................................................................................................... ....... 1-45 multiplication and division instructions ............................................................................... 1-45 ports ............................................................................................................................... .......... 1-45 serial i/o ............................................................................................................................... .. 1-45 a-d converter ......................................................................................................................... 1-45 instruction excution time ...................................................................................................... 1-45 data required for mask orders ................................................................................ 1-46 data required for rom writing orders ................................................................. 1-46 rom programming method .............................................................................................. 1-46 functional description supplement ......................................................................... 1-47 interrupt ............................................................................................................................... .... 1-47 timing after interrupt ............................................................................................................. 1-48 a-d converter ......................................................................................................................... 1-49 misrg ............................................................................................................................... ...... 1-51 3850 group ............................................................................................................................. 1- 53
ii 3850/3851 group users manual table of contents chapter 2 application 2.1 i/o port ............................................................................................................................... ...... 2-2 2.1.1 memory map ................................................................................................................... 2-2 2.1.2 relevant registers .......................................................................................................... 2-2 2.1.3 handling of unused pins ............................................................................................... 2-3 2.1.4 notes on input and output pins ................................................................................... 2-4 2.1.5 termination of unused pins .......................................................................................... 2-5 2.2 timer ............................................................................................................................... .......... 2-6 2.2.1 memory map ................................................................................................................... 2-6 2.2.2 relevant registers .......................................................................................................... 2-6 2.2.3 timer application examples ........................................................................................ 2-12 2.2.4 notes on timer .............................................................................................................. 2-25 2.3 serial i/o ............................................................................................................................... . 2-26 2.3.1 memory map ................................................................................................................. 2-26 2.3.2 relevant registers ........................................................................................................ 2-27 2.3.3 serial i/o connection examples ................................................................................. 2-31 2.3.4 setting of serial i/o transfer data format ................................................................. 2-33 2.3.5 serial i/o application examples ................................................................................. 2-34 2.3.6 notes on serial i/o ...................................................................................................... 2-52 2.4 muti-master i 2 c-bus interface .......................................................................................... 2-55 2.4.1 memory map ................................................................................................................. 2-55 2.4.2 relevant registers ........................................................................................................ 2-55 2.4.3 i 2 c-bus overview ......................................................................................................... 2-61 2.4.4 communication format ................................................................................................. 2-62 2.4.5 synchronization and arbitration lost .......................................................................... 2-63 2.4.6 smbus communication usage example ................................................................... 2-65 2.4.7 notes on muti-master i 2 c-bus interface .................................................................. 2-81 2.4.8 notes on programming for smbus interface ........................................................... 2-84 2.5 pwm ............................................................................................................................... ......... 2-85 2.5.1 memory map ................................................................................................................. 2-85 2.5.2 relevant registers ........................................................................................................ 2-85 2.5.3 pwm output circuit application example ................................................................... 2-87 2.5.4 notes on pwm ............................................................................................................. 2-89 2.6 a-d converter ....................................................................................................................... 2-90 2.6.1 memory map ................................................................................................................. 2-90 2.6.2 relevant registers ........................................................................................................ 2-90 2.6.3 a-d converter application examples .......................................................................... 2-93 2.6.4 notes on a-d converter .............................................................................................. 2-95 2.7 reset ............................................................................................................................... ........ 2-96 2.7.1 connection example of reset ic ................................................................................ 2-96 2.7.2 notes on reset pin ................................................................................................... 2-97
iii 3850/3851 group users manual table of contents chapter 3 appendix 3.1 electrical characteristics ..................................................................................................... 3-2 3.1.1 absolute maximum ratings ............................................................................................ 3-2 3.1.2 recommended operating conditions ............................................................................ 3-3 3.1.3 electrical characteristics ................................................................................................ 3-5 3.1.4 a-d converter characteristics ....................................................................................... 3-6 3.1.5 timing requirements ...................................................................................................... 3-7 3.1.6 switching characteristics ............................................................................................... 3-8 3.1.7 multi-master i 2 c-bus bus line characteristics .......................................................... 3-11 3.2 standard characteristics .................................................................................................... 3-12 3.2.1 power source current characteristic examples ........................................................ 3-12 3.2.2 port standard characteristic examples ...................................................................... 3-15 3.2.3 a-d conversion standard characteristics ................................................................... 3-17 3.3 notes on use ........................................................................................................................ 3-18 3.3.1 notes on interrupts ...................................................................................................... 3-18 3.3.2 notes on timer .............................................................................................................. 3-19 3.3.3 notes on serial i/o ...................................................................................................... 3-19 3.3.4 notes on multi-master i 2 c-bus interface ................................................................. 3-21 3.3.5 notes on a-d converter .............................................................................................. 3-24 3.3.6 notes on watchdog timer ............................................................................................ 3-24 3.3.7 notes on reset pin ................................................................................................... 3-24 3.3.8 notes on input and output pins ................................................................................. 3-25 3.3.9 notes on low-speed operation mode ........................................................................ 3-26 3.3.10 notes on restarting oscillation .................................................................................. 3-26 3.3.11 notes on programming .............................................................................................. 3-27 3.3.12 programming and test of built-in prom version ................................................... 3-29 3.3.13 notes on built-in prom version .............................................................................. 3-29 3.3.14 termination of unused pins ...................................................................................... 3-31 3.4 countermeasures against noise ...................................................................................... 3-32 3.4.1 shortest wiring length .................................................................................................. 3-32 3.4.2 connection of bypass capacitor across v ss line and v cc line ............................... 3-34 3.4.3 wiring to analog input pins ........................................................................................ 3-35 3.4.4 oscillator concerns ....................................................................................................... 3-35 3.4.5 setup for i/o ports ....................................................................................................... 3-37 3.4.6 providing of watchdog timer function by software .................................................. 3-38 3.5 list of registers ................................................................................................................... 3-39 3.6 mask rom confirmation form ........................................................................................... 3-56 3.7 rom programming confirmation form ............................................................................ 3-66 3.8 mark specification form ..................................................................................................... 3-74 3.9 package outline ................................................................................................................... 3-76 3.10 machine instructions ........................................................................................................ 3-78 3.11 list of instruction codes ................................................................................................. 3-89 3.12 sfr memory map .............................................................................................................. 3-90 3.13 pin configurations ............................................................................................................. 3-91
3850/3851 group users manual i list of figures list of figures chapter 1 hardware fig. 1 m38513m4-xxxfp/sp pin configuration ......................................................................... 1-2 fig. 2 functional block diagram ................................................................................................... 1-3 fig. 3 part numbering .................................................................................................................... 1-5 fig. 4 memory expansion plan ..................................................................................................... 1-6 fig. 5 740 family cpu register structure ................................................................................... 1-7 fig. 6 register push and pop at interrupt generation and subroutine call ........................... 1-8 fig. 7 structure of cpu mode register ..................................................................................... 1-10 fig. 8 memory map diagram ...................................................................................................... 1-11 fig. 9 memory map of special function register (sfr) .......................................................... 1-12 fig. 10 port block diagram (1) ................................................................................................... 1-14 fig. 11 port block diagram (2) ................................................................................................... 1-15 fig. 12 interrupt control ............................................................................................................... 1-18 fig. 13 structure of interrupt-related registers (1) .................................................................. 1-18 fig. 14 structure of timer xy mode register ............................................................................ 1-19 fig. 15 structure of timer count source selection register ..................................................... 1-19 fig. 16 block diagram of timer x, timer 1 and timer 2 .......................................................... 1-20 fig. 17 block diagram of clock synchronous serial i/o .......................................................... 1-21 fig. 18 operation of clock synchronous serial i/o function ................................................... 1-21 fig. 19 block diagram of uart serial i/o ............................................................................... 1-22 fig. 20 operation of uart serial i/o function ........................................................................ 1-23 fig. 21 structure of serial i/o control registers ....................................................................... 1-24 fig. 22 block diagram of multi-master i 2 c-bus interface ...................................................... 1-25 fig. 23 structure of i 2 c address register .................................................................................. 1-26 fig. 24 structure of i 2 c clock control register ......................................................................... 1-27 fig. 25 sda/scl pin selection bit ............................................................................................. 1-28 fig. 26 structure of i 2 c control register .................................................................................... 1-28 fig. 27 structure of i 2 c status register ..................................................................................... 1-30 fig. 28 interrupt request signal generating timing .................................................................. 1-30 fig. 29 start condition generating timing diagram .............................................................. 1-31 fig. 30 stop condition generating timing diagram ................................................................ 1-31 fig. 31 start/stop condition detecting timing diagram ..................................................... 1-31 fig. 32 stop condition detecting timing diagram ................................................................... 1-31 fig. 33 structure of i 2 c start/stop condition control register ............................................ 1-33 fig. 34 address data communication format ............................................................................ 1-33 fig. 35 timing of pwm period ................................................................................................... 1-36 fig. 36 block diagram of pwm function ................................................................................... 1-36 fig. 37 structure of pwm control register ............................................................................... 1-37 fig. 38 pwm output timing when pwm register or pwm prescaler is changed ................ 1-37 fig. 39 structure of ad control register ................................................................................... 1-38 fig. 40 structure of a-d conversion registers ......................................................................... 1-38 fig. 41 block diagram of a-d converter ................................................................................... 1-38 fig. 42 block diagram of watchdog timer ................................................................................ 1-39 fig. 43 structure of watchdog timer control register ............................................................. 1-39 fig. 44 reset circuit example .................................................................................................... 1-40 fig. 45 reset sequence .............................................................................................................. 1-40 fig. 46 internal status at reset .................................................................................................. 1-41 fig. 47 ceramic resonator circuit .............................................................................................. 1-42
ii 3850/3851 group users manual list of figures chapter 2 application fig. 2.1.1 memory map of registers relevant to i/o port ......................................................... 2-2 fig. 2.1.2 structure of port pi (i = 0, 1, 2, 3, 4) ...................................................................... 2-2 fig. 2.1.3 structure of port pi direction register (i = 0, 1, 2, 3, 4) ....................................... 2-3 fig. 2.2.1 memory map of registers relevant to timers ............................................................ 2-6 fig. 2.2.2 structure of prescaler 12, prescaler x, prescaler y .............................................. 2-6 fig. 2.2.3 structure of timer 1 .................................................................................................... 2-7 fig. 2.2.4 structure of timer 2, timer x, timer y ................................................................... 2-7 fig. 2.2.5 structure of timer xy mode register ........................................................................ 2-8 fig. 2.2.6 structure of timer count source set register ........................................................... 2-9 fig. 2.2.7 structure of interrupt request register 1 ................................................................. 2-10 fig. 2.2.8 structure of interrupt request register 2 ................................................................. 2-10 fig. 2.2.9 structure of interrupt control register 1 .................................................................. 2-11 fig. 2.2.10 structure of interrupt control register 2 ................................................................ 2-11 fig. 2.2.11 timers connection and setting of division ratios ................................................. 2-13 fig. 2.2.12 relevant registers setting ....................................................................................... 2-14 fig. 2.2.13 control procedure ..................................................................................................... 2-15 fig. 2.2.14 peripheral circuit example ....................................................................................... 2-16 fig. 2.2.15 timers connection and setting of division ratios ................................................. 2-16 fig. 2.2.16 relevant registers setting ....................................................................................... 2-17 fig. 2.2.17 control procedure ..................................................................................................... 2-18 fig 2.2.18 judgment method of valid/invalid of input pulses ................................................ 2-19 fig. 2.2.19 relevant registers setting ....................................................................................... 2-20 fig. 2.2.20 control procedure ..................................................................................................... 2-21 fig. 2.2.21 timers connection and setting of division ratios ................................................. 2-22 fig. 2.2.22 relevant registers setting ....................................................................................... 2-23 fig. 2.2.23 control procedure ..................................................................................................... 2-24 fig. 2.3.1 memory map of registers relevant to serial i/o ..................................................... 2-26 fig. 2.3.2 structure of transmit/receive buffer register ........................................................ 2-27 fig. 2.3.3 structure of serial i/o status register ..................................................................... 2-27 fig. 2.3.4 structure of serial i/o control register .................................................................... 2-28 fig. 2.3.5 structure of uart control register .......................................................................... 2-28 fig. 2.3.6 structure of baud rate generator ............................................................................. 2-29 fig. 2.3.7 structure of interrupt edge selection register ........................................................ 2-29 fig. 2.3.8 structure of interrupt request register 2 ................................................................. 2-29 fig. 2.3.9 structure of interrupt control register 2 .................................................................. 2-30 fig. 48 external clock input circuit ............................................................................................ 1-42 fig. 49 structure of misrg ........................................................................................................ 1-43 fig. 50 system clock generating circuit block diagram (single-chip mode) ........................ 1-43 fig. 51 state transitions of system clock ................................................................................. 1-44 fig. 52 programming and testing of one time prom version ............................................ 1-46 fig. 53 timing chart after an interrupt occurs ......................................................................... 1-48 fig. 54 time up to execution of the interrupt processing routine ........................................ 1-48 fig. 55 a-d conversion equivalent circuit ................................................................................. 1-50 fig. 56 a-d conversion timing chart .......................................................................................... 1-50 fig. 57 structure of misrg ........................................................................................................ 1-52 fig. 58 structure of i 2 c start/stop condition control register ......................................... 1-52 fig. 59 memory expansion plan of 3850 group ....................................................................... 1-53 fig. 60 structure of interrupt request register 1 of 3850 group ........................................... 1-54 fig. 61 structure of interrupt control register 1 of 3850 group ............................................ 1-54
3850/3851 group users manual iii list of figures fig. 2.3.10 serial i/o connection examples (1) ....................................................................... 2-31 fig. 2.3.11 serial i/o connection examples (2) ....................................................................... 2-32 fig. 2.3.12 serial i/o transfer data format ............................................................................... 2-33 fig. 2.3.13 connection diagram ................................................................................................. 2-34 fig. 2.3.14 timing chart (using clock synchronous serial i/o) .............................................. 2-34 fig. 2.3.15 registers setting relevant to transmitting side ..................................................... 2-35 fig. 2.3.16 registers setting relevant to receiving side ......................................................... 2-36 fig. 2.3.17 control procedure of transmitting side .................................................................. 2-37 fig. 2.3.18 control procedure of receiving side ...................................................................... 2-38 fig. 2.3.19 connection diagram ................................................................................................. 2-39 fig. 2.3.20 timing chart .............................................................................................................. 2-39 fig. 2.3.21 registers setting relevant to serial i/o ................................................................. 2-40 fig. 2.3.22 setting of serial i/o transmission data ................................................................. 2-40 fig. 2.3.23 control procedure of serial i/o .............................................................................. 2-41 fig. 2.3.24 connection diagram ................................................................................................. 2-42 fig. 2.3.25 timing chart .............................................................................................................. 2-43 fig. 2.3.26 relevant registers setting ....................................................................................... 2-43 fig. 2.3.27 control procedure of master unit ........................................................................... 2-44 fig. 2.3.28 control procedure of slave unit ............................................................................. 2-45 fig. 2.3.29 connection diagram (communication using uart) ............................................ 2-46 fig. 2.3.30 timing chart (using uart) ..................................................................................... 2-46 fig. 2.3.31 registers setting relevant to transmitting side ..................................................... 2-48 fig. 2.3.32 registers setting relevant to receiving side ......................................................... 2-49 fig. 2.3.33 control procedure of transmitting side .................................................................. 2-50 fig. 2.3.34 control procedure of receiving side ...................................................................... 2-51 fig. 2.3.35 sequence of setting serial i/o control register again ......................................... 2-53 fig. 2.4.1 memory map of registers relevant to i 2 c-bus interface ...................................... 2-55 fig. 2.4.2 structure of i 2 c data shift register ........................................................................... 2-55 fig. 2.4.3 structure of i 2 c address register ............................................................................. 2-56 fig. 2.4.4 structure of i 2 c status register ................................................................................. 2-56 fig. 2.4.5 structure of i 2 c control register ............................................................................... 2-57 fig. 2.4.6 structure of i 2 c clock control register ..................................................................... 2-58 fig. 2.4.7 structure of i 2 c start/stop condition control register ..................................... 2-59 fig. 2.4.8 structure of interrupt request register 1 ................................................................. 2-59 fig. 2.4.9 structure of interrupt control register 1 .................................................................. 2-60 fig. 2.4.10 i 2 c-bus connection structure ................................................................................. 2-61 fig. 2.4.11 i 2 c-bus communication format example .............................................................. 2-62 fig. 2.4.12 restart condition of master reception .............................................................. 2-63 fig. 2.4.13 scl waveforms when synchronizing clocks ......................................................... 2-64 fig. 2.4.14 initial setting example using smbus communication ......................................... 2-66 fig. 2.4.15 read word protocol communication as smbus master device ....................... 2-67 fig. 2.4.16 transmission process of start condition and slave address ......................... 2-68 fig. 2.4.17 transmission process of command ....................................................................... 2-69 fig. 2.4.18 transmission process of restart condition and slave address + read bit . 2-70 fig. 2.4.19 reception process of lower data ........................................................................... 2-71 fig. 2.4.20 reception process of upper data .......................................................................... 2-72 fig. 2.4.21 generating of stop condition ............................................................................... 2-73 fig. 2.4.22 communication example as smbus slave device .............................................. 2-74 fig. 2.4.23 reception process of start condition and slave address .............................. 2-75 fig. 2.4.24 reception process of command ............................................................................. 2-76 fig. 2.4.25 reception process of restart condition and slave address + read bit ....... 2-77 fig. 2.4.26 transmission process of lower data ...................................................................... 2-78
iv 3850/3851 group users manual list of figures fig. 2.4.27 transmission process of upper data ..................................................................... 2-79 fig. 2.4.28 reception of stop condition ................................................................................. 2-80 fig. 2.5.1 memory map of registers relavant to pwm ........................................................... 2-85 fig. 2.5.2 structure of pwm control register ........................................................................... 2-85 fig. 2.5.3 structure of pwm prescaler ..................................................................................... 2-86 fig. 2.5.4 structure of pwm register ........................................................................................ 2-86 fig. 2.5.5 connection diagram ................................................................................................... 2-87 fig. 2.5.6 pwm output timing ..................................................................................................... 2-87 fig. 2.5.7 setting of related registers ....................................................................................... 2-88 fig. 2.5.8 pwm output ................................................................................................................ 2-88 fig. 2.5.9 control procedure ....................................................................................................... 2-89 fig. 2.6.1 memory map of registers relevant to a-d converter ............................................ 2-90 fig. 2.6.2 structure of a-d control register .............................................................................. 2-90 fig. 2.6.3 structure of a-d conversion register (high-order) ................................................. 2-91 fig. 2.6.4 structure of a-d conversion register (low-order) ................................................... 2-91 fig. 2.6.5 structure of interrupt request register 2 ................................................................. 2-92 fig. 2.6.6 structure of interrupt control register 2 .................................................................. 2-92 fig. 2.6.7 connection diagram ................................................................................................... 2-93 fig. 2.6.8 relevant registers setting ......................................................................................... 2-93 fig. 2.6.9 control procedure for 8-bit read .............................................................................. 2-94 fig. 2.6.10 control procedure for 10-bit read .......................................................................... 2-94 fig. 2.7.1 example of poweron reset circuit ............................................................................ 2-96 fig. 2.7.2 ram backup system .................................................................................................. 2-96 chapter 3 appendix fig. 3.1.1 circuit for measuring output switching characteristics (1) ..................................... 3-9 fig. 3.1.2 circuit for measuring output switching characteristics (2) ..................................... 3-9 fig. 3.1.3 timing chart ................................................................................................................ 3-10 fig. 3.1.4 timing diagram of multi-master i 2 c-bus ................................................................ 3-11 fig. 3.2.1 power source current characteristic examples (f(x in ) = 8mhz, in high-speed mode) ............................................................................................................................... ...... 3-12 fig. 3.2.2 power source current characteristic examples (f(x in ) = 8mhz, in middle-speed mode) ............................................................................................................................... ...... 3-12 fig. 3.2.3 power source current characteristic examples (f(x in ) = 4mhz, in high-speed mode) ............................................................................................................................... ...... 3-13 fig. 3.2.4 power source current characteristic examples (f(x in ) = 4mhz, in middle-speed mode) ............................................................................................................................... ...... 3-13 fig. 3.2.5 power source current characteristic examples (f(x cin ) = 32khz, in low-speed mode) ............................................................................................................................... ...... 3-14 fig. 3.2.6 standard characteristic examples of cmos output port at p-channel drive ..... 3-15 fig. 3.2.7 standard characteristic examples of cmos output port at n-channel drive ..... 3-15 fig. 3.2.8 standard characteristic examples of n-channel open-drain output port at n-channel drive ............................................................................................................................. 3- 16 fig. 3.2.9 standard characteristic examples of cmos large current output port at n-channel drive ............................................................................................................................. 3- 16 fig. 3.2.10 a-d conversion standard characteristics ............................................................... 3-17 fig. 3.3.1 sequence of switch the detection edge .................................................................. 3-18 fig. 3.3.2 sequence of check of interrupt request bit ............................................................ 3-18 fig. 3.3.3 sequence of setting serial i/o control register again ........................................... 3-20 fig. 3.3.4 ceramic resonator circuit .......................................................................................... 3-26 fig. 3.3.5 initialization of processor status register ................................................................ 3-27 fig. 3.3.6 sequence of plp instruction execution .................................................................. 3-27
3850/3851 group users manual v list of figures fig. 3.3.7 stack memory contents after php instruction execution ..................................... 3-27 fig. 3.3.8 interrupt routine .......................................................................................................... 3-28 fig. 3.3.9 status flag at decimal calculations .......................................................................... 3-28 fig. 3.3.10 programming and testing of one time prom version ...................................... 3-29 fig. 3.4.1 selection of packages ............................................................................................... 3-32 fig. 3.4.2 wiring for the reset pin ......................................................................................... 3-32 fig. 3.4.3 wiring for clock i/o pins ........................................................................................... 3-33 fig. 3.4.4 wiring for cnvss pin ............................................................................................... 3-33 fig. 3.4.5 wiring for the v pp pin of the one time prom and the eprom version ......... 3-34 fig. 3.4.6 bypass capacitor across the vss line and the vcc line ....................................... 3-34 fig. 3.4.7 analog signal line and a resistor and a capacitor ................................................ 3-35 fig. 3.4.8 wiring for a large current signal line ...................................................................... 3-35 fig. 3.4.9 wiring of reset pin ................................................................................................. 3-36 fig. 3.4.10 vss pattern on the underside of an oscillator ..................................................... 3-36 fig. 3.4.11 setup for i/o ports ................................................................................................... 3-37 fig. 3.4.12 watchdog timer by software ................................................................................... 3-38 fig. 3.5.1 structure of port pi (i=0, 1, 2, 3, 4) ....................................................................... 3-39 fig. 3.5.2 structure of port pi direction register(i=0, 1, 2, 3, 4) .......................................... 3-39 fig. 3.5.3 structure of transmit/receive buffer register ........................................................ 3-40 fig. 3.5.4 structure of serial i/o status register ..................................................................... 3-40 fig. 3.5.5 structure of serial i/o control register .................................................................... 3-41 fig. 3.5.6 structure of uart control register .......................................................................... 3-41 fig. 3.5.7 structure of baud rate generator ............................................................................. 3-42 fig. 3.5.8 structure of pwm control register ........................................................................... 3-42 fig. 3.5.9 structure of pwm prescaler ..................................................................................... 3-43 fig. 3.5.10 structure of pwm register ...................................................................................... 3-43 fig. 3.5.11 structure of prescaler 12, prescaler x, prescaler y .......................................... 3-44 fig. 3.5.12 structure of timer 1 ................................................................................................ 3-44 fig. 3.5.13 structure of timer 2, timer x, timer y ............................................................... 3-45 fig. 3.5.14 structure of timer count source selection register .............................................. 3-45 fig. 3.5.15 structure of timer xy mode register .................................................................... 3-46 fig. 3.5.16 structure of i 2 c data shift register ......................................................................... 3-47 fig. 3.5.17 structure of i 2 c address register ........................................................................... 3-47 fig. 3.5.18 structure of i 2 c status register .............................................................................. 3-48 fig. 3.5.19 structure of i 2 c control register ............................................................................. 3-48 fig. 3.5.20 structure of i 2 c clock control register ................................................................... 3-49 fig. 3.5.21 structure of i 2 c start/stop condition control register ................................... 3-50 fig. 3.5.22 structure of a-d control register ............................................................................ 3-50 fig. 3.5.23 structure of a-d conversion register(low-order) .................................................. 3-51 fig. 3.5.24 structure of a-d conversion register (high-order) ............................................... 3-51 fig. 3.5.25 structure of misrg ................................................................................................. 3-52 fig. 3.5.26 structure of watchdog timer control register ....................................................... 3-52 fig. 3.5.27 structure of interrupt edge selection register ...................................................... 3-53 fig. 3.5.28 structure of cpu mode register ............................................................................ 3-53 fig. 3.5.29 structure of interrupt request register 1 ............................................................... 3-54 fig. 3.5.30 structure of interrupt request register 2 ............................................................... 3-54 fig. 3.5.31 structure of interrupt control register 1 ................................................................ 3-55 fig. 3.5.32 structure of interrupt control register 2 ................................................................ 3-55 fig. 3.13.1 m38513m4-xxxfp/sp pin configuration ............................................................... 3-91
3850/3851 group users manual i list of tables list of tables chapter 1 hardware table 1 pin description ................................................................................................................. 1-4 table 2 push and pop instructions of accumulator or processor status register ................. 1-8 table 3 set and clear instructions of each bit of processor status register ......................... 1-9 table 4 i/o port function table ................................................................................................... 1-13 table 5 interrupt vector address and priority .......................................................................... 1-17 table 6 multi-master i 2 c-bus interface functions ................................................................... 1-25 table 7 set values of i 2 c clock control register and scl frequency .................................. 1-27 table 8 start condition generating timing table .................................................................. 1-31 table 9 stop condition generating timing table ..................................................................... 1-31 table 10 start condition/stop condition detecting conditions ............................................ 1-31 table 11 recommended set value to start/stop condition set bits (ssc4Cssc0) for each oscillation frequency .................................................................................................... 1-33 table 12 programming adapter .................................................................................................. 1-46 table 13 interrupt sources, vector addresses and interrupt priority ..................................... 1-47 table 14 change of a-d conversion register during a-d conversion .................................. 1-49 chapter 2 application table 2.1.1 handling of unused pins .......................................................................................... 2-3 table 2.2.1 cntr 0 / cntr 1 active edge switch bit function ................................................... 2-8 table 2.3.1 setting example of baud rate generator values and transfer bit rate values 2-47 table 2.4.1 set value of i 2 c clock control register and scl frequency .............................. 2-58 chapter 3 appendix table 3.1.1 absolute maximum ratings ....................................................................................... 3-2 table 3.1.2 recommended operating conditions (1) ................................................................ 3-3 table 3.1.3 recommended operating conditions (2) ................................................................ 3-4 table 3.1.4 electrical characteristics (1) ..................................................................................... 3-5 table 3.1.5 electrical characteristics (2) ................................................................................... 3-6 table 3.1.6 a-d converter characteristics .................................................................................. 3-6 table 3.1.7 timing requirements (1) ........................................................................................... 3-7 table 3.1.8 timing requirements (2) ........................................................................................... 3-7 table 3.1.9 switching requirements (1) ...................................................................................... 3-8 table 3.1.10 switching requirements (2) .................................................................................... 3-8 table 3.1.11 multi-master i 2 c-bus bus line characteristics .................................................. 3-11 table 3.3.1 programming adapters ........................................................................................... 3-29 table 3.3.2 prom programmer address setting ..................................................................... 3-30 table 3.5.1 cntr 0 / cntr 1 active edge switch bit function ................................................. 3-46 table 3.5.2 set value of i 2 c clock control register and scl frequency .............................. 3-49
chapter 1 chapter 1 hardware descripion features application pin configuration functional block pin description part numbering group expansion functional description notes on programming data required for mask orders data required for rom writing orders rom programming method functional descripion supplement
1-2 3850/3851 group users manual hardware description the 3851 group is the 8-bit microcomputer based on the 740 fam- ily core technology. the 3851 group is designed for the household products and office automation equipment and includes serial i/o functions, 8-bit timer, a-d converter, and i 2 c-bus interface. features l basic machine-language instructions ...................................... 71 l minimum instruction execution time .................................. 0.5 m s (at 8 mhz oscillation frequency) l memory size rom ................................................................ 16 k to 24 kbytes ram ................................................................... 512 to 640 bytes l programmable input/output ports ............................................ 34 l interrupts ................................................. 16 sources, 16 vectors l timers ............................................................................. 8-bit 5 4 l serial i/o ....................... 8-bit 5 1(uart or clock-synchronized) l multi-master i 2 c-bus interface (option) ....................... 1 channel l pwm ............................................................................... 8-bit 5 1 l a-d converter ............................................... 10-bit 5 5 channels l watchdog timer ............................................................ 16-bit 5 1 l clock generating circuit ..................................... built-in 2 circuits (connect to external ceramic resonator or quartz-crystal oscillator) pin configuration (top view) fig. 1 m38513m4-xxxfp/sp pin configuration l power source voltage in high-speed mode .................................................. 4.0 to 5.5 v (at 8 mhz oscillation frequency) in high-speed mode .................................................. 2.7 to 5.5 v (at 4 mhz oscillation frequency) in middle-speed mode............................................... 2.7 to 5.5 v (at 8 mhz oscillation frequency) in low-speed mode .................................................... 2.7 to 5.5 v (at 32 khz oscillation frequency) l power dissipation in high-speed mode .......................................................... 34 mw (at 8 mhz oscillation frequency, at 5 v power source voltage) in low-speed mode ............................................................ 60 m w (at 32 khz oscillation frequency, at 3 v power source voltage) l operating temperature range.................................... C20 to 85c application office automation equipment, fa equipment, household products, consumer electronics, etc. p4 0 /cntr 1 p4 1 /int 0 p4 2 /int 1 p4 3 /int 2 av ss p4 4 /int 3 /pwm v ref v cc p3 1 /an 1 p3 2 /an 2 p0 0 p0 4 p0 5 p0 6 p0 7 p1 1 p1 2 p1 3 /(led 0 ) p1 4 /(led 1 ) p1 5 /(led 2 ) p1 0 p0 1 p0 2 p3 0 /an 0 p3 3 /an 3 p3 4 /an 4 p0 3 40 41 42 22 23 24 25 26 27 28 29 30 31 32 34 35 36 37 38 39 33 3 2 1 21 20 19 18 17 16 15 14 13 12 11 9 8 7 6 5 4 10 m38513m4-xxxfp m38513m4-xxxsp p1 6 /(led 3 ) p1 7 /(led 4 ) p2 7 /cntr 0 /s rdy p2 6 /s clk p2 5 /scl 2 /txd p2 4 /sda 2 /rxd p2 3 /scl 1 p2 2 /sda 1 cnv ss p2 1 /x cin p2 0 /x cout reset x in x out v ss package type : fp ........................... 42p2r-a (42-pin plastic-molded ssop) package type : sp ........................... 42p4b (42-pin shrink plastic-molded dip) description/features/application/pin configuration
3850/3851 group users manual hardware 1-3 functional block diagram fig. 2 functional block diagram functional block int 0 C cntr 0 cntr 1 v ref av ss r a m r o m c p u a x y s pc h pc l ps v ss 21 reset 18 v cc 1 15 cnv ss 23 x in 19 20 si/o(8) reset input clock generating circuit main-clock input main-clock output a-d converter (10) timer y( 8 ) timer x( 8 ) prescaler 12(8) prescaler x(8) prescaler y(8) timer 1( 8 ) timer 2( 8 ) sub-clock input x out x cin x cout sub-clock output watchdog timer reset p2(8) p3(5) i/o port p2 i/o port p3 p4(5) i/o port p4 i c int 3 4 6 8 5 7 39 41 38 40 42 9 11 13 17 10 12 14 16 p1(8) i/o port p1 22 24 26 28 23 25 27 29 p0(8) i/o port p0 30 31 32 3334 35 36 37 pwm (8) 2 x cin x cout functional block
1-4 3850/3851 group users manual hardware v cc , v ss pin description functions name pin ?apply voltage of 2.7 v C 5.5 v to vcc, and 0 v to vss. ?this pin controls the operation mode of the chip. ?normally connected to v ss . ?reset input pin for active l. ?input and output pins for the clock generating circuit. ?connect a ceramic resonator or quartz-crystal oscillator between the x in and x out pins to set the oscillation frequency. ?when an external clock is used, connect the clock source to the x in pin and leave the x out pin open. ?8-bit cmos i/o port. ?i/o direction register allows each pin to be individually programmed as either input or output. ?cmos compatible input level. ?cmos 3-state output structure. ?p1 3 to p1 7 (5 bits) are enabled to output large current for led drive (m38513e4/m4). ?p1 0 to p1 7 (8 bits) are enabled to output large current for led drive (m38514e6/m6). power source table 1 pin description function except a port function ? sub-clock generating circuit i/o pins (connect a resonator) clock input clock output i/o port p0 i/o port p1 i/o port p2 cnv ss input cnv ss reset reset input x in x out p0 0 Cp0 7 p1 0 Cp1 7 p2 0 /x cout p2 1 /x cin p2 2 /sda 1 p2 3 /scl 1 p2 4 /sda 2 /rxd p2 5 /scl 2 /txd p2 6 /s clk p2 7 /cntr 0 / s rdy i/o port p3 i/o port p4 ?8-bit cmos i/o port. ?i/o direction register allows each pin to be individually programmed as either input or output. ?cmos compatible input level. ?p2 2 to p2 5 can be switched between cmos compat- ible input level or smbus input level in the i 2 c-bus interface function. ?p2 0 , p2 1 , p2 4 to p2 7 : cmos3-state output structure. ?p2 4 , p2 5 : n-channel open-drain structure in the i 2 c- bus interface function. ?p2 2 , p2 3 : n-channel open-drain structure. ?8-bit cmos i/o port with the same function as port p0. ?cmos compatible input level. ?cmos 3-state output structure. ?8-bit cmos i/o port with the same function as port p0. ?cmos compatible input level. ?cmos 3-state output structure. ? i 2 c-bus interface function pins ? i 2 c-bus interface function pin/ serial i/o function pins ? serial i/o function pin ? serial i/o function pin/ timer x function pin ? a-d converter input pin ? timer y function pin ? interrupt input pins ? interrupt input pin ? pwm output pin p3 0 /an 0 C p3 4 /an 4 p4 0 /cntr 1 p4 1 /int 0 C p4 3 /int 2 p4 4 /int 3 /pwm pin description
3850/3851 group users manual hardware 1-5 part numbering m3851 3 m 4 - xxx fp product name package type fp : 42p2r-a sp : 42p4b rom number omitted in the one time prom version shipped in blank. rom/prom size 1 2 3 4 5 6 7 8 : 4096 bytes : 8192 bytes : 12288 bytes : 16384 bytes : 20480 bytes : 24576 bytes : 28672 bytes : 32768 bytes the first 128 bytes and the last 2 bytes of rom are reserved areas ; they cannot be used. memory type m e : mask rom version : one time prom version ram size 0 1 2 3 4 : 192 bytes : 256 bytes : 384 bytes : 512 bytes : 640 bytes ?: standard ?is omitted in the one time prom version shipped in blank. 9: 36864 bytes : 40960 bytes : 45056 bytes : 49152 bytes : 53248 bytes : 57344 bytes : 61440 bytes a b c d e f 5 6 7 8 9 : 768 bytes : 896 bytes : 1024 bytes : 1536 bytes : 2048 bytes part numbering fig. 3 part numbering
1-6 3850/3851 group users manual hardware group expansion mitsubishi plans to expand the 3851 group as follows: memory type support for mask rom and one time prom versions. memory size rom size ............................................................ 16 k to 24 kbytes ram size .............................................................. 512 to 640 bytes packages 42p2r-a ............................................ 42-pin plastic molded ssop 42p4b ......................................... 42-pin shrink plastic-molded dip fig. 4 memory expansion plan memory expansion plan 48k rom size (bytes) 32k 28k 24k 20k 16k 12k 8k 128 192 256 ram size (bytes) 384 512 640 768 896 1024 m38513e4fp/sp m38513m4-xxxfp/sp new production m38514e6fp/sp m38514m6-xxxfp/sp mass production group expansion
3850/3851 group users manual hardware 1-7 functional description central processing unit (cpu) the 3851 group uses the standard 740 family instruction set. re- fer to the table of 740 family addressing modes and machine instructions or the 740 series software manual for details on the instruction set. machine-resident 740 family instructions are as follows: the fst and slw instructions cannot be used. the stp, wit, mul, and div instructions can be used. the central processing unit (cpu) has the six registers. accumulator (a) the accumulator is an 8-bit register. data operations such as data transfer, etc., are executed mainly through the accumulator. index register x (x), index register y (y) both index register x and index register y are 8-bit registers. in the index addressing modes, the value of the operand is added to the contents of register x or register y and specifies the real address. when the t flag in the processor status register is set to 1, the value contained in index register x becomes the address for the sec- ond operand. stack pointer (s) the stack pointer is an 8-bit register used during sub-routine calls and interrupts. the stack is used to store the current address data and processor status when branching to subroutines or interrupt rou- tines. the lower eight bits of the stack address are determined by the con- tents of the stack pointer. the upper eight bits of the stack address are determined by the stack page selection bit. if the stack page selection bit is 0, then the ram in the zero page is used as the stack area. if the stack page selection bit is 1, then ram in page 1 is used as the stack area. the stack page selection bit is located in the sfr area in the zero page. note that the initial value of the stack page selection bit var- ies with each microcomputer type. also some microcomputer types have no stack page selection bit and the upper eight bits of the stack address are fixed. the operations of pushing register contents onto the stack and popping them from the stack are shown in figure 8. program counter (pc) the program counter is a 16-bit counter consisting of two 8-bit regis- ters pc h and pc l . it is used to indicate the address of the next in- struction to be executed. fig. 5 740 family cpu register structure b7 b0 x b7 b0 s b7 b0 y b7 b0 pc l processor status register (ps) carry flag b7 b0 b7 b0 a b15 pc h zero flag interrupt disable flag decimal mode flag break flag index x mode flag overflow flag negative flag program counter stack pointer index register y index register x accumulator c z i d b t v n functional description
1-8 3850/3851 group users manual hardware table 2 push and pop instructions of accumulator or processor status register accumulator processor status register push instruction to stack pha php pop instruction from stack pla plp fig. 6 register push and pop at interrupt generation and subroutine call execute jsr on-going routine m (s) (pc h ) (s) (s ?1) m (s) (pc l ) execute rts (pc l ) m (s) (s) (s ?1) (s) (s + 1) (s) (s + 1) (pc h ) m (s) subroutine restore return address store return address on stack m (s) (ps) execute rti (ps) m (s) (s) (s ?1) (s) (s + 1) interrupt service routine restore contents of processor status register m (s) (pc h ) (s) (s ?1) m (s) (pc l ) (s) (s ?1) (pc l ) m (s) (s) (s + 1) (s) (s + 1) (pc h ) m (s) restore return address i flag ??to ?? fetch the jump vector store return address on stack store contents of processor status register on stack interrupt request (note) note : the condition to enable the interrupt interrupt enable bit is ? interrupt disable flag is ? functional description
3850/3851 group users manual hardware 1-9 processor status register (ps) the processor status register is an 8-bit register consisting of flags which indicate the status of the processor after an arithmetic opera- tion. branch operations can be performed by testing the carry (c) flag, zero (z) flag, overflow (v) flag, or the negative (n) flag. in deci- mal mode, the z, v, n flags are not valid. after reset, the interrupt disable (i) flag is set to 1, but all other flags are undefined. since the index x mode (t) and decimal mode (d) flags directly affect arithmetic operations, they should be initialized in the beginning of a program. (1) carry flag (c) the c flag contains a carry or borrow generated by the arithmetic logic unit (alu) immediately after an arithmetic operation. it can also be changed by a shift or rotate instruction. (2) zero flag (z) the z flag is set if the result of an immediate arithmetic operation or a data transfer is 0, and cleared if the result is anything other than 0. (3) interrupt disable flag (i) the i flag disables all interrupts except for the interrupt generated by the brk instruction. interrupts are disabled when the i flag is 1. when an interrupt occurs, this flag is automatically set to 1 to prevent other interrupts from interfering until the current interrupt is serviced. (4) decimal mode flag (d) the d flag determines whether additions and subtractions are executed in binary or decimal. binary arithmetic is executed when this flag is 0; decimal arithmetic is executed when it is 1. decimal correction is automatic in decimal mode. only the adc and sbc instructions can be used for decimal arithmetic. (5) break flag (b) the b flag is used to indicate that the current interrupt was generated by the brk instruction. the brk flag in the processor status register is always 0. when the brk instruction is used to generate an interrupt, the processor status register is pushed onto the stack with the break flag set to 1. the saved processor status is the only place where the break flag is ever set. (6) index x mode flag (t) when the t flag is 0, arithmetic operations are performed between accumulator and memory, e.g. the results of an operation between two memory locations is stored in the accumulator. when the t flag is 1, direct arithmetic operations and direct data transfers are enabled between memory locations, i.e. between memory and memory, memory and i/o, and i/o and i/o. in this case, the result of an arithmetic operation performed on data in memory location 1 and memory location 2 is stored in memory location 1. the address of memory location 1 is specified by index register x, and the address of memory location 2 is specified by normal addressing modes. (7) overflow flag (v) the v flag is used during the addition or subtraction of one byte of signed data. it is set if the result exceeds +127 to -128. when the bit instruction is executed, bit 6 of the memory location operated on by the bit instruction is stored in the overflow flag. (8) negative flag (n) the n flag is set if the result of an arithmetic operation or data transfer is negative. when the bit instruction is executed, bit 7 of the memory location operated on by the bit instruction is stored in the negative flag. table 3 set and clear instructions of each bit of processor status register set instruction clear instruction c flag z flag i flag d flag b flag t flag v flag n flag sec clc _ _ sei cli sed cld _ _ set clt clv _ _ _ functional description
1-10 3850/3851 group users manual hardware [cpu mode register (cpum)] 003b 16 the cpu mode register contains the stack page selection bit, etc. the cpu mode register is allocated at address 003b 16 . fig. 7 structure of cpu mode register cpu mode register ( cpum : address 003b 16 ) b7 b0 stack page selection bit 0 : 0 page 1 : 1 page not used (return ??when read) (do not write ??to this bit.) processor mode bits b1 b0 0 0 : single-chip mode 0 1 : 1 0 : not available 1 1 : port x c switch bit 0 : i/o port function (stop oscillating) 1 : x cin ? cout oscillating function main clock (x in ? out ) stop bit 0 : oscillating 1 : stopped main clock division ratio selection bits b7 b6 0 0 : f = f(x in )/2 (high-speed mode) 0 1 : f = f(x in )/8 (middle-speed mode) 1 0 : f = f(x cin )/2 (low-speed mode) 1 1 : not available functional description
3850/3851 group users manual hardware 1-11 memory special function register (sfr) area the special function register area in the zero page contains con- trol registers such as i/o ports and timers. ram ram is used for data storage and for stack area of subroutine calls and interrupts. rom the first 128 bytes and the last 2 bytes of rom are reserved for device testing and the rest is user area for storing programs. interrupt vector area the interrupt vector area contains reset and interrupt vectors. zero page access to this area with only 2 bytes is possible in the zero page addressing mode. special page access to this area with only 2 bytes is possible in the special page addressing mode. fig. 8 memory map diagram 0100 16 0000 16 0040 16 ff00 16 ffdc 16 fffe 16 ffff 16 192 256 384 512 640 768 896 1024 1536 2048 3072 4032 xxxx 16 00ff 16 013f 16 01bf 16 023f 16 02bf 16 033f 16 03bf 16 043f 16 063f 16 083f 16 0c3f 16 0fff 16 4096 8192 12288 16384 20480 24576 28672 32768 36864 40960 45056 49152 53248 57344 61440 f000 16 e000 16 d000 16 c000 16 b000 16 a000 16 9000 16 8000 16 7000 16 6000 16 5000 16 4000 16 3000 16 2000 16 1000 16 f080 16 e080 16 d080 16 c080 16 b080 16 a080 16 9080 16 8080 16 7080 16 6080 16 5080 16 4080 16 3080 16 2080 16 1080 16 yyyy 16 zzzz 16 ram rom 0440 16 sfr area not used interrupt vector area rom area reserved rom area (128 bytes) zero page special page ram area ram size (bytes) address xxxx 16 rom size (bytes) address yyyy 16 reserved rom area address zzzz 16 reserved area functional description
1-12 3850/3851 group users manual hardware fig. 9 memory map of special function register (sfr) 0020 16 0021 16 0022 16 0023 16 0024 16 0025 16 0026 16 0027 16 0028 16 0029 16 002a 16 002b 16 002c 16 002d 16 002e 16 002f 16 0030 16 0031 16 0032 16 0033 16 0034 16 0035 16 0036 16 0037 16 0038 16 0039 16 003a 16 003b 16 003c 16 003d 16 003e 16 003f 16 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 0010 16 0011 16 0012 16 0013 16 0014 16 0015 16 0016 16 0017 16 0018 16 0019 16 001a 16 001b 16 001c 16 001d 16 001e 16 001f 16 port p0 (p0) port p0 direction register (p0d) port p1 (p1) port p1 direction register (p1d) port p2 (p2) port p2 direction register (p2d) port p3 (p3) port p3 direction register (p3d) port p4 (p4) port p4 direction register (p4d) transmit/receive buffer register (tb/rb) serial i/o status register (siosts) serial i/o control register (siocon) uart control register (uartcon) baud rate generator (brg) interrupt control register 2 (icon2) a-d conversion low-order register (adl) prescaler y (prey) timer y (ty) a-d control register (adcon) a-d conversion high-order register (adh) interrupt edge selection register (intedge) cpu mode register (cpum) interrupt request register 1 (ireq1) interrupt request register 2 (ireq2) interrupt control register 1 (icon1) prescaler 12 (pre12) timer 2 (t2) prescaler x (prex) timer x (tx) timer 1 (t1) timer xy mode register (tm) i 2 c data shift register (s0) i 2 c address register (s0d) i 2 c status register (s1) i 2 c control register (s1d) i 2 c clock control register (s2) i 2 c start/stop condition control register (s2d) misrg watchdog timer control register (wdtcon) pwm control register (pwmcon) pwm prescaler (prepwm) pwm register (pwm) timer count source selection register (tcss) reserved ] reserved ] reserved ] ] reserved : do not write ??to this address. reserved ] functional description
3850/3851 group users manual hardware 1-13 pin name input/output i/o structure non-port function ref.no. table 4 i/o port function related sfrs i/o ports the i/o ports have direction registers which determine the input/ output direction of each individual pin. each bit in a direction reg- ister corresponds to one pin, and each pin can be set to be input port or output port. when 0 is written to the bit corresponding to a pin, that pin be- comes an input pin. when 1 is written to that bit, that pin becomes an output pin. if data is read from a pin which is set to output, the value of the port output latch is read, not the value of the pin itself. pins set to input are floating. if a pin set to input is written to, only the port output latch is written to and the pin remains floating. port p0 port p1 port p3 input/output, individual bits cmos compatible input level cmos 3-state output sub-clock generating circuit cpu mode register (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) p0 0 Cp0 7 p1 0 Cp1 7 p2 0 /x cout p2 1 /x cin p2 2 /sda 1 p2 3 /scl 1 p2 4 /sda 2 /rxd p2 5 /scl 2 /txd port p2 p2 6 /s clk p2 7 /cntr 0 /s rdy p3 0 /an 0 p3 4 /an 4 p4 0 /cntr 1 p4 1 /int 0 p4 3 /int 2 p4 4 /int 3 /pwm port p4 cmos compatible input level cmos/smbus input level (when selecting i 2 c-bus interface function) n-channel open-drain output cmos compatible input level cmos/smbus input level (when selecting i 2 c-bus interface function) cmos 3-state output n-channel open-drain output (when selecting i 2 c-bus interface function) cmos compatible input level cmos 3-state output i 2 c-bus interface func- tion i/o i 2 c-bus interface func- tion i/o serial i/o function i/o serial i/o function i/o serial i/o function i/o timer x function i/o a-d conversion input i 2 c control register i 2 c control register serial i/o control register serial i/o control register serial i/o control register timer xy mode register a-d control register timer y function i/o external interrupt input external interrupt input pwm output timer xy mode register interrupt edge selection register interrupt edge selection register pwm control register (13) functional description
1-14 3850/3851 group users manual hardware fig. 10 port block diagram (1) (1) port p0, p1 direction register data bus port latch (2) port p2 0 port x c switch bit oscillator port p2 1 data bus port latch direction register port x c switch bit (3) port p2 1 port x c switch bit data bus port latch direction register sub-clock generating circuit input (4) port p2 2 data bus port latch direction register sda output i c-bus interface enable bit sda/scl pin selection bit sda input 2 (5) port p2 3 data bus port latch direction register scl output i c-bus interface enable bit sda/scl pin selection bit scl input 2 (6) port p2 4 data bus port latch direction register sda output serial i/o enable bit receive enable bit i c-bus interface enable bit sda/scl pin selection bit 2 sda input serial i/o input (7) port p2 5 data bus port latch direction register scl output i c bus interface enable bit sda/scl pin selection bit serial i/o enable bit transmit enable bit 2 scl input serial i/o output p-channel output disable bit (8) port p2 6 data bus port latch direction register serial clock output serial i/o mode selection bit serial i/o enable bit serial i/o enable bit serial i/o clock selection bit external clock input functional description
3850/3851 group users manual hardware 1-15 fig. 11 port block diagram (2) (10) port p3 0 ?3 4 direction register data bus port latch (11) port p4 0 cntr 1 interrupt input data bus port latch direction register (9) port p2 7 data bus port latch direction register timer output serial i/o enable bit s rdy output enable bit serial i/o mode selection bit cntr 0 interrupt input serial ready output a-d converter input analog input pin selection bit (12) port p4 1 ?4 3 direction register data bus port latch interrupt input pulse output mode timer output (13) port p4 4 pwm output data bus port latch direction register pwm output enable bit pulse output mode pulse output mode functional description
1-16 3850/3851 group users manual hardware interrupts interrupts occur by 16 sources among 16 sources: seven external, eight internal, and one software. interrupt control each interrupt is controlled by an interrupt request bit, an interrupt enable bit, and the interrupt disable flag except for the software in- terrupt set by the brk instruction. an interrupt occurs if the corresponding interrupt request and enable bits are 1 and the in- terrupt disable flag is 0. interrupt enable bits can be set or cleared by software. interrupt request bits can be cleared by software, but cannot be set by software. the brk instruction cannot be disabled with any flag or bit. the i (interrupt disable) flag disables all interrupts except the brk in- struction interrupt. when several interrupts occur at the same time, the interrupts are received according to priority. interrupt operation by acceptance of an interrupt, the following operations are auto- matically performed: 1. the contents of the program counter and the processor status register are automatically pushed onto the stack. 2. the interrupt disable flag is set and the corresponding interrupt request bit is cleared. 3. the interrupt jump destination address is read from the vector table into the program counter. n notes when the active edge of an external interrupt (int 0 Cint 3 , scl/ sda, cntr 0 , cntr 1 ) is set, the corresponding interrupt request bit may also be set. therefore, take the following sequence: 1. disable the interrupt 2. change the interrupt edge selection register (scl/sda interrupt pin polarity selection bit for scl/sda; the timer xy mode register for cntr 0 and cntr 1 ) 3. clear the interrupt request bit to 0 4. accept the interrupt. functional description
3850/3851 group users manual hardware 1-17 interrupt request generating conditions remarks interrupt source low fffc 16 high fffd 16 priority 1 table 5 interrupt vector addresses and priority notes 1: vector addresses contain interrupt jump destination addresses. 2: reset function in the same way as an interrupt with the highest priority. vector addresses (note 1) reset (note 2) int 0 scl, sda int 1 int 2 int 3 i 2 c timer x timer y timer 1 timer 2 serial i/o reception serial i/o transmission cntr 0 cntr 1 a-d converter brk instruction at reset at detection of either rising or falling edge of int 0 input at detection of either rising or falling edge of int 1 input at detection of either rising or falling edge of int 2 input at detection of either rising or falling edge of int 3 input at completion of data transfer at completion of serial i/o data reception at completion of serial i/o trans- fer shift or when transmission buffer is empty at timer x underflow at timer y underflow at timer 1 underflow at timer 2 underflow non-maskable external interrupt (active edge selectable) external interrupt (active edge selectable) valid when serial i/o is selected valid when serial i/o is selected external interrupt (active edge selectable) stp release timer underflow external interrupt (active edge selectable) at detection of either rising or falling edge of scl or sda input at detection of either rising or falling edge of cntr 0 input at detection of either rising or falling edge of cntr 1 input at completion of a-d conversion at brk instruction execution external interrupt (active edge selectable) external interrupt (active edge selectable) external interrupt (active edge selectable) non-maskable software interrupt fffa 16 fff8 16 fff6 16 fff4 16 fff2 16 fff0 16 ffee 16 ffec 16 ffea 16 ffe8 16 ffe6 16 ffe4 16 ffe2 16 ffe0 16 ffde 16 fffb 16 fff9 16 fff7 16 fff5 16 fff3 16 fff1 16 ffef 16 ffed 16 ffeb 16 ffe9 16 ffe7 16 ffe5 16 ffe3 16 ffe1 16 ffdf 16 ffdc 16 ffdd 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 functional description
1-18 3850/3851 group users manual hardware fig. 12 interrupt control fig. 13 structure of interrupt-related registers (1) interrupt disable flag (i) interrupt request interrupt request bit interrupt enable bit brk instruction reset b7 b0 b7 b0 b7 b0 b7 b0 b7 b0 interrupt edge selection register (intedge : address 003a 16 ) interrupt request register 1 int 0 interrupt request bit scl/sda interrupt request bit int 1 interrupt request bit int 2 interrupt request bit int 3 interrupt request bit i 2 c interrupt request bit timer x interrupt request bit timer y interrupt request bit interrupt control register 1 int 0 interrupt enable bit scl/sda interrupt enable bit int 1 interrupt enable bit int 2 interrupt enable bit int 3 interrupt enable bit i 2 c interrupt enable bit timer x interrupt enable bit timer y interrupt enable bit 0 : no interrupt request issued 1 : interrupt request issued (ireq1 : address 003c 16 ) (icon1 : address 003e 16 ) interrupt request register 2 timer 1 interrupt request bit timer 2 interrupt request bit serial i/o reception interrupt request bit serial i/o transmit interrupt request bit cntr 0 interrupt request bit cntr 1 interrupt request bit ad converter interrupt request bit not used (returns ??when read) (ireq2 : address 003d 16 ) interrupt control register 2 timer 1 interrupt enable bit timer 2 interrupt enable bit serial i/o reception interrupt enable bit serial i/o transmit interrupt enable bit cntr 0 interrupt enable bit cntr 1 interrupt enable bit ad converter interrupt enable bit not used (returns ??when read) (do not write ??to this bit) 0 : interrupts disabled 1 : interrupts enabled (icon2 : address 003f 16 ) 0 : no interrupt request issued 1 : interrupt request issued 0 : interrupts disabled 1 : interrupts enabled int 0 active edge selection bit int 1 active edge selection bit int 2 active edge selection bit int 3 active edge selection bit reserved(do not write ??to this bit) not used (returns ??when read) 0 : falling edge active 1 : rising edge active functional description
3850/3851 group users manual hardware 1-19 timers the 3851 group has four timers: timer x, timer y, timer 1, and timer 2. the division ratio of each timer or prescaler is given by 1/(n + 1), where n is the value in the corresponding timer or prescaler latch. all timers are count down. when the timer reaches 00 16 , an un- derflow occurs at the next count pulse and the corresponding timer latch is reloaded into the timer and the count is continued. when a timer underflows, the interrupt request bit corresponding to that timer is set to 1. timer 1 and timer 2 the count source of prescaler 12 is the oscillation frequency which is selected by timer 12 count source selection bit. the out- put of prescaler 12 is counted by timer 1 and timer 2, and a timer underflow sets the interrupt request bit. timer x and timer y timer x and timer y can each select in one of four operating modes by setting the timer xy mode register. (1) timer mode the timer counts the count source selected by timer count source selection bit. (2) pulse output mode the timer counts the count source selected by timer count source selection bit. whenever the contents of the timer reach 00 16 , the signal output from the cntr 0 (or cntr 1 ) pin is inverted. if the cntr 0 (or cntr 1 ) active edge selection bit is 0, output begins at h. if it is 1, output starts at l. when using a timer in this mode, set the corresponding port p2 7 ( or port p4 0 ) direction register to out- put mode. (3) event counter mode operation in event counter mode is the same as in timer mode, ex- cept that the timer counts signals input through the cntr 0 or cntr 1 pin. when the cntr 0 (or cntr 1 ) active edge selection bit is 0, the rising edge of the cntr 0 (or cntr 1 ) pin is counted. when the cntr 0 (or cntr 1 ) active edge selection bit is 1, the falling edge of the cntr 0 (or cntr 1 ) pin is counted. (4) pulse width measurement mode if the cntr 0 (or cntr 1 ) active edge selection bit is 0, the timer counts the selected signals by the count source selection bit while the cntr 0 (or cntr 1 ) pin is at h. if the cntr 0 (or cntr 1 ) ac- tive edge selection bit is 1, the timer counts it while the cntr 0 (or cntr 1 ) pin is at l. the count can be stopped by setting 1 to the timer x (or timer y) count stop bit in any mode. the corresponding interrupt request bit is set each time a timer underflows. fig. 14 structure of timer xy mode register n note when switching the count source by the timer 12, x and y count source selection bit, the value of timer count is altered in unconsiderable amount owing to generating of a thin pulses in the count input signals. therefore, select the timer count source before set the value to the prescaler and the timer. fig. 15 structure of timer count source selection register timer x count stop bit 0: count start 1: count stop timer xy mode register (tm : address 0023 16 ) timer y operating mode bit 0 0: timer mode 0 1: pulse output mode 1 0: event counter mode 1 1: pulse width measurement mode cntr 1 active edge selection bit 0: interrupt at falling edge count at rising edge in event counter mode 1: interrupt at rising edge count at falling edge in event counter mode b7 cntr 0 active edge selection bit 0: interrupt at falling edge count at rising edge in event counter mode 1: interrupt at rising edge count at falling edge in event counter mode b0 timer x operating mode bit 0 0: timer mode 0 1: pulse output mode 1 0: event counter mode 1 1: pulse width measurement mode b1b0 b5b4 timer y count stop bit 0: count start 1: count stop timer count source selection register (tcss : address 0028 16 ) b7 b0 timer x count source selection bit 0 : f(x in )/16 (f(x cin )/16 at low-speed mode) 1 : f(x in )/2 (f(x cin )/2 at low-speed mode) timer y count source selection bit 0 : f(x in )/16 (f(x cin )/16 at low-speed mode) 1 : f(x in )/2 (f(x cin )/2 at low-speed mode) timer 12 count source selection bit 0 : f(x in )/16 (f(x cin )/16 at low-speed mode) 1 : f(x cin ) not used (returns ??when read) functional description
1-20 3850/3851 group users manual hardware fig. 16 block diagram of timer x, timer y, timer 1, and timer 2 q q ? ? p2 7 /cntr 0 q q p4 0 /cntr 1 ? ? r r ? ? ? ? t t prescaler x latch (8) prescaler x (8) timer x latch (8) timer x (8) to timer x interrupt request bit toggle flip-flop timer x count stop bit pulse width measurement mode event counter mode to cntr 0 interrupt request bit pulse output mode port p2 7 latch port p2 7 direction register cntr 0 active edge selection bit timer x latch write pulse pulse output mode timer mode pulse output mode prescaler y latch (8) prescaler y (8) timer y latch (8) timer y (8) to timer y interrupt request bit toggle flip-flop timer y count stop bit to cntr 1 interrupt request bit pulse output mode port p4 0 latch port p4 0 direction register cntr 1 active edge selection bit timer y latch write pulse pulse output mode timer mode pulse output mode data bus data bus prescaler 12 latch (8) prescaler 12 (8) timer 1 latch (8) timer 1 (8) data bus timer 2 latch (8) timer 2 (8) to timer 2 interrupt request bit to timer 1 interrupt request bit cntr 0 active edge selection bit cntr 1 active edge selection bit pulse width measure- ment mode event counter mode f(x cin ) timer 12 count source selection bit f(x in )/16 f(x in )/2 timer y count source selection bit f(x in )/16 f(x in )/2 timer x count source selection bit f(x in )/16 functional description
3850/3851 group users manual hardware 1-21 serial i/o serial i/o can be used as either clock synchronous or asynchro- nous (uart) serial i/o. a dedicated timer is also provided for baud rate generation. (1) clock synchronous serial i/o mode clock synchronous serial i/o mode can be selected by setting the serial i/o mode selection bit of the serial i/o control register (bit 6 of address 001a 16 ) to 1. for clock synchronous serial i/o, the transmitter and the receiver must use the same clock. if an internal clock is used, transfer is started by a write signal to the tb/rb. fig. 17 block diagram of clock synchronous serial i/o fig. 18 operation of clock synchronous serial i/o function d 7 d 7 d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 0 d 1 d 2 d 3 d 4 d 5 d 6 rbf = 1 tsc = 1 tbe = 0 tbe = 1 tsc = 0 transfer shift clock (1/2 to 1/2048 of the internal clock, or an external clock) serial output txd serial input rxd write pulse to receive/transmit buffer register (address 0018 16 ) overrun error (oe) detection notes 1: as the transmit interrupt (ti), either when the transmit buffer has emptied (tbe=1) or after the transmit shift operation has ended (tsc=1), by setting the transmit interrupt source selection bit (tic) of the serial i/o control register. 2: if data is written to the transmit buffer register when tsc=0, the transmit clock is generated continuously and serial data is output continuously from the txd pin. 3: the receive interrupt (ri) is set when the receive buffer full flag (rbf) becomes ??. receive enable signal s rdy 1/4 1/4 f/f p2 6 /s clk serial i/o status register serial i/o control register p2 7 /s rdy p2 4 /r x d p2 5 /t x d x in receive buffer register address 0018 16 receive shift register receive buffer full flag (rbf) receive interrupt request (ri) clock control circuit shift clock serial i/o synchronous clock selection bit frequency division ratio 1/(n+1) baud rate generator address 001c 16 brg count source selection bit clock control circuit falling-edge detector transmit buffer register data bus address 0018 16 shift clock transmit shift completion flag (tsc) transmit buffer empty flag (tbe) transmit interrupt request (ti) transmit interrupt source selection bit address 0019 16 data bus address 001a 16 transmit shift register functional description
1-22 3850/3851 group users manual hardware (2) asynchronous serial i/o (uart) mode clock asynchronous serial i/o mode (uart) can be selected by clearing the serial i/o mode selection bit (b6) of the serial i/o con- trol register to 0. eight serial data transfer formats can be selected, and the transfer formats used by a transmitter and receiver must be identical. the transmit and receive shift registers each have a buffer, but the two buffers have the same address in memory. since the shift reg- ister cannot be written to or read from directly, transmit data is written to the transmit buffer register, and receive data is read from the receive buffer register. the transmit buffer register can also hold the next data to be transmitted, and the receive buffer register can hold a character while the next character is being received. fig.19 block diagram of uart serial i/o x in 1/4 oe pe fe 1/16 1/16 data bus receive buffer register address 0018 16 receive shift register receive buffer full flag (rbf) receive interrupt request (ri) baud rate generator frequency division ratio 1/(n+1) address 001c 16 st/sp/pa generator transmit buffer register data bus transmit shift register address 0018 16 transmit shift completion flag (tsc) transmit buffer empty flag (tbe) transmit interrupt request (ti) address 0019 16 st detector sp detector uart control register address 001b 16 character length selection bit address 001a 16 brg count source selection bit transmit interrupt source selection bit serial i/o synchronous clock selection bit clock control circuit character length selection bit 7 bits 8 bits serial i/o control register p2 6 /s clk1 serial i/o status register p2 4 /r x d p2 5 /t x d functional description
3850/3851 group users manual hardware 1-23 fig. 20 operation of uart serial i/o function [transmit buffer register/receive buffer register (tb/rb)] 0018 16 the transmit buffer register and the receive buffer register are lo- cated at the same address. the transmit buffer is write-only and the receive buffer is read-only. if a character bit length is 7 bits, the msb of data stored in the receive buffer is 0. [serial i/o status register (siosts)] 0019 16 the read-only serial i/o status register consists of seven flags (bits 0 to 6) which indicate the operating status of the serial i/o function and various errors. three of the flags (bits 4 to 6) are valid only in uart mode. the receive buffer full flag (bit 1) is cleared to 0 when the receive buffer register is read. if there is an error, it is detected at the same time that data is transferred from the receive shift register to the receive buffer reg- ister, and the receive buffer full flag is set. a write to the serial i/o status register clears all the error flags oe, pe, fe, and se (bit 3 to bit 6, respectively). writing 0 to the serial i/o enable bit sioe (bit 7 of the serial i/o control register) also clears all the status flags, including the error flags. bits 0 to 6 of the serial i/o status register are initialized to 0 at re- set, but if the transmit enable bit (bit 4) of the serial i/o control register has been set to 1, the transmit shift completion flag (bit 2) and the transmit buffer empty flag (bit 0) become 1. [serial i/o control register (siocon)] 001a 16 the serial i/o control register consists of eight control bits for the serial i/o function. [uart control register (uartcon)] 001b 16 the uart control register consists of four control bits (bits 0 to 3) which are valid when asynchronous serial i/o is selected and set the data format of an data transfer and one bit (bit 4) which is al- ways valid and sets the output structure of the p2 5 /t x d pin. [baud rate generator (brg)] 001c 16 the baud rate generator determines the baud rate for serial trans- fer. the baud rate generator divides the frequency of the count source by 1/(n + 1), where n is the value written to the baud rate genera- tor. n note when using the serial i/o, clear the i 2 c-bus interface enable bit to 0 or the sda/scl pin selection bit to 0. tsc=0 tbe=1 rbf=0 tbe=0 tbe=0 rbf=1 rbf=1 st d 0 d 1 sp d 0 d 1 st sp tbe=1 tsc=1 st d 0 d 1 sp d 0 d 1 st sp transmit or receive clock transmit buffer write signal generated at 2nd bit in 2-stop-bit mode 1 start bit 7 or 8 data bit 1 or 0 parity bit 1 or 2 stop bit (s) 1: error flag detection occurs at the same time that the rbf flag becomes ??(at 1st stop bit, during reception). 2: as the transmit interrupt (ti), when either the tbe or tsc flag becomes ?,? can be selected to occur depending on the settin g of the transmit interrupt source selection bit (tic) of the serial i/o control register. 3: the receive interrupt (ri) is set when the rbf flag becomes ?. 4: after data is written to the transmit buffer when tsc=1, 0.5 to 1.5 cycles of the data shift cycle is necessary until changing to tsc=0. notes serial output t x d serial input r x d receive buffer read signal functional description
1-24 3850/3851 group users manual hardware fig. 21 structure of serial i/o control registers b7 b7 transmit buffer empty flag (tbe) 0: buffer full 1: buffer empty receive buffer full flag (rbf) 0: buffer empty 1: buffer full transmit shift completion flag (tsc) 0: transmit shift in progress 1: transmit shift completed overrun error flag (oe) 0: no error 1: overrun error parity error flag (pe) 0: no error 1: parity error framing error flag (fe) 0: no error 1: framing error summing error flag (se) 0: (oe) u (pe) u (fe)=0 1: (oe) u (pe) u (fe)=1 not used (returns ??when read) serial i/o status register serial i/o control register b0 b0 brg count source selection bit (css) 0: f(x in ) 1: f(x in )/4 serial i/o synchronous clock selection bit (scs) 0: brg output divided by 4 when clock synchronous serial i/o is selected, brg output divided by 16 when uart is selected. 1: external clock input when clock synchronous serial i/o is selected, external clock input divided by 16 when uart is selected. s rdy output enable bit (srdy) 0: p2 7 pin operates as ordinary i/o pin 1: p2 7 pin operates as s rdy output pin transmit interrupt source selection bit (tic) 0: interrupt when transmit buffer has emptied 1: interrupt when transmit shift operation is completed transmit enable bit (te) 0: transmit disabled 1: transmit enabled receive enable bit (re) 0: receive disabled 1: receive enabled serial i/o mode selection bit (siom) 0: clock asynchronous (uart) serial i/o 1: clock synchronous serial i/o serial i/o enable bit (sioe) 0: serial i/o disabled (pins p2 4 to p2 7 operate as ordinary i/o pins) 1: serial i/o enabled (pins p2 4 to p2 7 operate as serial i/o pins) b7 uart control register character length selection bit (chas) 0: 8 bits 1: 7 bits parity enable bit (pare) 0: parity checking disabled 1: parity checking enabled parity selection bit (pars) 0: even parity 1: odd parity stop bit length selection bit (stps) 0: 1 stop bit 1: 2 stop bits p2 5 /t x d p-channel output disable bit (poff) 0: cmos output (in output mode) 1: n-channel open drain output (in output mode) not used (return ??when read) b0 (siosts : address 0019 16 ) (siocon : address 001a 16 ) (uartcon : address 001b 16 ) functional description
3850/3851 group users manual hardware 1-25 function in conformity with philips i 2 c-bus standard: 10-bit addressing format 7-bit addressing format high-speed clock mode standard clock mode in conformity with philips i 2 c-bus standard: master transmission master reception slave transmission slave reception 16.1 khz to 400 khz (at f = 4 mhz) table 6 multi-master i 2 c-bus interface functions item format communication mode system clock f = f(x in )/2 (high-speed mode) f = f(x in )/8 (middle-speed mode) multi-master i 2 c-bus interface the multi-master i 2 c-bus interface is a serial communications cir- cuit, conforming to the philips i 2 c-bus data transfer format. this interface, offering both arbitration lost detection and a synchro- nous functions, is useful for the multi-master serial communications. figure 19 shows a block diagram of the multi-master i 2 c-bus in- terface and table 4 lists the multi-master i 2 c-bus interface functions. this multi-master i 2 c-bus interface consists of the i 2 c address register, the i 2 c data shift register, the i 2 c clock control register, the i 2 c control register, the i 2 c status register, the i 2 c start/stop condition control register and other control circuits. when using the multi-master i 2 c-bus interface, set 1 mhz or more to f . note: mitsubishi electric corporation assumes no responsibility for in- fringement of any third-partys rights or originating in the use of the connection control function between the i 2 c-bus interface and the ports scl 1 , scl 2 , sda 1 and sda 2 with the bit 6 of i 2 c control regis- ter (002e 16 ). fig. 22 block diagram of multi-master i 2 c-bus interface ] : purchase of mitsubishi electric corporations i 2 c components conveys a license under the philips i 2 c patent rights to use these components an i 2 c system, provided that the system conforms to the i 2 c standard specification as defined by philips. scl clock frequency i 2 c address register b7 b0 sad6 sad5 sad4 sad3 sad2 sad1 sad0 rbw noise elimination circuit address comparator b7 i 2 c data shift register b0 data control circuit system clock ( f ) interrupt generating circuit interrupt request signal (iicirq) b7 mst trx bb pin al aas ad0 lrb b0 s1 b7 b0 tiss 10bit sad als bc2 bc1 bc0 s1d bit counter bb circuit clock control circuit noise elimination circuit b7 b0 ack ack bit fast mode ccr4 ccr3 ccr2 ccr1 ccr0 internal data bus clock division s 0 s2 s0d al circuit es0 sis i 2 c start/stop condition control register sip ssc4 ssc3 ssc2 ssc1 ssc0 i 2 c clock control register i 2 c status register s2d i 2 c clock control register s1d i c control register 2 serial data (s da ) serial clock (s cl ) tsel functional description
1-26 3850/3851 group users manual hardware [i 2 c data shift register (s0)] 002b 16 the i 2 c data shift register (s0 : address 002b 16 ) is an 8-bit shift register to store receive data and write transmit data. when transmit data is written into this register, it is transferred to the outside from bit 7 in synchronization with the scl clock, and each time one-bit data is output, the data of this register are shifted by one bit to the left. when data is received, it is input to this register from bit 0 in synchronization with the scl clock, and each time one-bit data is input, the data of this register are shifted by one bit to the left. the minimum 2 machine cycles are required from the rising of the s cl clock until input to this register. the i 2 c data shift register is in a write enable status only when the i 2 c-bus interface enable bit (es0 bit : bit 3 of address 002e 16 ) of the i 2 c control register is 1. the bit counter is reset by a write in- struction to the i 2 c data shift register. when both the es0 bit and the mst bit of the i 2 c status register (address 002d 16 ) are 1, the scl is output by a write instruction to the i 2 c data shift register. reading data from the i 2 c data shift register is always enabled re- gardless of the es0 bit value. [i 2 c address register (s0d)] 002c 16 the i 2 c address register (address 002c 16 ) consists of a 7-bit slave address and a read/write bit. in the addressing mode, the slave address written in this register is compared with the address data to be received immediately after the start condition is de- tected. ?bit 0: read/write bit (rwb) this is not used in the 7-bit addressing mode. in the 10-bit ad- dressing mode, the first address data to be received is compared with the contents (sad6 to sad0 + rbw) of the i 2 c address reg- ister. the rwb bit is cleared to 0 automatically when the stop condi- tion is detected. ?bits 1 to 7: slave address (sad0Csad6) these bits store slave addresses. regardless of the 7-bit address fig. 23 structure of i 2 c address register sad6 sad5 sad4 sad3 sad2 sad1 sad0 rwb slave address i 2 c address register (s0d: address 002c 16 ) read/write bit b7 b0 functional description
3850/3851 group users manual hardware 1-27 table 7 set values of i 2 c clock control register and scl frequency fig. 24 structure of i 2 c clock control register scl frequency (at f = 4 mhz, unit : khz) setting value of ccr4Cccr0 standard clock mode setting disabled setting disabled setting disabled high-speed clock mode ccr4 0 0 0 0 0 0 0 1 1 1 ccr3 0 0 0 0 0 0 0 1 1 1 ccr2 0 0 0 0 1 1 1 1 1 1 ccr1 0 0 1 1 0 0 1 0 1 1 ccr0 0 1 0 1 0 1 0 1 0 1 setting disabled setting disabled setting disabled 34.5 33.3 32.3 100 83.3 333 250 400 (note 3) 166 C (note 2) C (note 2) [i 2 c clock control register (s2)] 002f 16 the i 2 c clock control register (address 002f 16 ) is used to set ack control, scl mode and scl frequency. ?bits 0 to 4: scl frequency control bits (ccr0Cccr4) these bits control the scl frequency. refer to table 5. ?bit 5: scl mode specification bit (fast mode) this bit specifies the scl mode. when this bit is set to 0, the standard clock mode is selected. when the bit is set to 1, the high-speed clock mode is selected. when connecting the bus of the high-speed mode i 2 c bus stan- dard (maximum 400 kbits/s), use 8 mhz or more oscillation frequency f(x in ) and 2 division clock. ?bit 6: ack bit (ack bit) this bit sets the sda status when an ack clock ] is generated. when this bit is set to 0, the ack return mode is selected and sda goes to l at the occurrence of an ack clock. when the bit is set to 1, the ack non-return mode is selected. the sda is held in the h status at the occurrence of an ack clock. however, when the slave address agree with the address data in the reception of address data at ack bit = 0, the sda is auto- matically made l (ack is returned). if there is a disagreement between the slave address and the address data, the sda is auto- matically made h (ack is not returned). ] ack clock: clock for acknowledgment ?bit 7: ack clock bit (ack) this bit specifies the mode of acknowledgment which is an ac- knowledgment response of data transfer. when this bit is set to 0, the no ack clock mode is selected. in this case, no ack clock occurs after data transmission. when the bit is set to 1, the ack clock mode is selected and the master generates an ack clock each completion of each 1-byte data transfer. the device for transmitting address data and control data releases the sda at the occurrence of an ack clock (makes sda h) and receives the ack bit generated by the data receiving device. note: do not write data into the i 2 c clock control register during transfer. if data is written during transfer, the i 2 c clock generator is reset, so that data cannot be transferred normally. ack ack bit fast mode ccr4 ccr3 ccr2 ccr1 ccr0 i 2 c clock control register (s2 : address 002f 16 ) b7 b0 s cl frequency control bits refer to table 5. s cl mode specification bit 0 : standard clock mode 1 : high-speed clock mode ack bit 0 : ack is returned. 1 : ack is not returned. ack clock bit 0 : no ack clock 1 : ack clock 500/ccr value (note 3) 1000/ccr value (note 3) 17.2 16.6 16.1 notes 1: duty of s cl clock output is 50 %. the duty becomes 35 to 45 % only when the high-speed clock mode is selected and ccr value = 5 (400 khz, at f = 4 mhz). h duration of the clock fluctuates from C4 to +2 machine cycles in the standard clock mode, and fluctuates from C2 to +2 machine cycles in the high-speed clock mode. in the case of negative fluctuation, the frequency does not increase because l duration is extended instead of h duration reduction. these are value when s cl clock synchronization by the synchro- nous function is not performed. ccr value is the decimal notation value of the s cl frequency control bits ccr4 to ccr0. 2: each value of s cl frequency exceeds the limit at f = 4 mhz or more. when using these setting value, use f of 4 mhz or less. 3: the data formula of s cl frequency is described below: f /(8 5 ccr value) standard clock mode f /(4 5 ccr value) high-speed clock mode (ccr value 1 5) f /(2 5 ccr value) high-speed clock mode (ccr value = 5) do not set 0 to 2 as ccr value regardless of f frequency. set 100 khz (max.) in the standard clock mode and 400 khz (max.) in the high-speed clock mode to the s cl frequency by set- ting the s cl frequency control bits ccr4 to ccr0. functional description
1-28 3850/3851 group users manual hardware fig. 26 structure of i 2 c control register [i 2 c control register (s1d)] 002e 16 the i 2 c control register (address 002e 16 ) controls data communi- cation format. ?bits 0 to 2: bit counter (bc0Cbc2) these bits decide the number of bits for the next 1-byte data to be transmitted. the i 2 c interrupt request signal occurs immediately after the number of count specified with these bits (ack clock is added to the number of count when ack clock is selected by ack clock bit (bit 7 of address 002f 16 )) have been transferred, and bc0 to bc2 are returned to 000 2 . also when a start condition is received, these bits become 000 2 and the address data is always transmitted and received in 8 bits. ?bit 3: i 2 c interface enable bit (es0) this bit enables to use the multi-master i 2 c-bus interface. when this bit is set to 0, the use disable status is provided, so that the sda and the scl become high-impedance. when the bit is set to 1, use of the interface is enabled. when es0 = 0, the following is performed. ? pin = 1, bb = 0 and al = 0 are set (which are bits of the i 2 c status register at address 002d 16 ). ? writing data to the i 2 c data shift register (address 002b 16 ) is dis- abled. ?bit 4: data format selection bit (als) this bit decides whether or not to recognize slave addresses. when this bit is set to 0, the addressing format is selected, so that address data is recognized. when a match is found between a slave address and address data as a result of comparison or when a general call (refer to i 2 c status register, bit 1) is received, transfer processing can be performed. when this bit is set to 1, the free data format is selected, so that slave addresses are not recognized. ?bit 5: addressing format selection bit (10bit sad) this bit selects a slave address specification format. when this bit is set to 0, the 7-bit addressing format is selected. in this case, only the high-order 7 bits (slave address) of the i 2 c address regis- ter (address 002c 16 ) are compared with address data. when this bit is set to 1, the 10-bit addressing format is selected, and all the bits of the i 2 c address register are compared with address data. ?bit 6: sda/scl pin selection bit this bit selects the input/output pins of scl and sda of the multi- master i 2 c-bus interface. ?bit 7: i 2 c-bus interface pin input level selection bit this bit selects the input level of the scl and sda pins of the multi-master i 2 c-bus interface. fig. 25 sda/scl pin selection bit scl sda multi-master i c-bus interface 2 tsel scl 1 /p2 3 scl 2 /txd/p2 5 sda 1 /p2 2 sda 2 /rxd/p2 4 tsel tsel tsel b7 tiss tsel 10 bit sad als es0 bc2 bc1 bc0 b0 sda/scl pin selection bit 0 : connect to ports p2 2 , p2 3 1 : connect to ports p2 4 , p2 5 i 2 c control register (s1d : address 002e 16 ) bit counter (number of transmit/receive bits) b2 b1 b0 0 0 0 : 8 0 0 1 : 7 0 1 0 : 6 0 1 1 : 5 1 0 0 : 4 1 0 1 : 3 1 1 0 : 2 1 1 1 : 1 i 2 c-bus interface enable bit 0 : disabled 1 : enabled data format selection bit 0 : addressing format 1 : free data format addressing format selection bit 0 : 7-bit addressing format 1 : 10-bit addressing format i 2 c-bus interface pin input level selection bit 0 : cmos input 1 : smbus input functional description
3850/3851 group users manual hardware 1-29 ?bit 4: scl pin low hold bit (pin) this bit generates an interrupt request signal. each time 1-byte data is transmitted, the pin bit changes from 1 to 0. at the same time, an interrupt request signal occurs to the cpu. the pin bit is set to 0 in synchronization with a falling of the last clock (in- cluding the ack clock) of an internal clock and an interrupt request signal occurs in synchronization with a falling of the pin bit. when the pin bit is 0, the scl is kept in the 0 state and clock generation is disabled. figure 25 shows an interrupt request signal generating timing chart. the pin bit is set to 1 in one of the following conditions: ? executing a write instruction to the i 2 c data shift register (ad- dress 002b 16 ). (this is the only condition which the prohibition of the internal clock is released and data can be communicated ex- cept for the start condition detection.) ? when the es0 bit is 0 ? at reset ? when writing 1 to the pin bit by software the conditions in which the pin bit is set to 0 are shown below: ? immediately after completion of 1-byte data transmission (includ- ing when arbitration lost is detected) ? immediately after completion of 1-byte data reception ? in the slave reception mode, with als = 0 and immediately af- ter completion of slave address agreement or general call address reception ? in the slave reception mode, with als = 1 and immediately af- ter completion of address data reception ?bit 5: bus busy flag (bb) this bit indicates the status of use of the bus system. when this bit is set to 0, this bus system is not busy and a start condition can be generated. the bb flag is set/reset by the scl, sda pins input signal regardless of master/slave. this flag is set to 1 by detecting the start condition, and is set to 0 by detecting the stop condition. the condition of these detecting is set by the start/stop condition setting bits (ssc4Cssc0) of the i 2 c start/stop condition control register (address 0030 16 ). when the es0 bit of the i 2 c control register (address 002e 16 ) is 0 or reset, the bb flag is set to 0. for the writing function to the bb flag, refer to the sections start condition generating method and stop condition gen- erating method described later. [i 2 c status register (s1)] 002d 16 the i 2 c status register (address 002d 16 ) controls the i 2 c-bus in- terface status. the low-order 4 bits are read-only bits and the high-order 4 bits can be read out and written to. set 0000 2 to the low-order 4 bits, because these bits become the reserved bits at writing. ?bit 0: last receive bit (lrb) this bit stores the last bit value of received data and can also be used for ack receive confirmation. if ack is returned when an ack clock occurs, the lrb bit is set to 0. if ack is not returned, this bit is set to 1. except in the ack mode, the last bit value of received data is input. the state of this bit is changed from 1 to 0 by executing a write instruction to the i 2 c data shift register (address 002b 16 ). ?bit 1: general call detecting flag (ad0) when the als bit is 0, this bit is set to 1 when a general call ] whose address data is all 0 is received in the slave mode. by a general call of the master device, every slave device receives con- trol data after the general call. the ad0 bit is set to 0 by detecting the stop condition or start condition, or reset. ] general call: the master transmits the general call address 00 16 to all slaves. ?bit 2: slave address comparison flag (aas) this flag indicates a comparison result of address data when the als bit is 0. in the slave receive mode, when the 7-bit addressing format is selected, this bit is set to 1 in one of the following conditions: ? the address data immediately after occurrence of a start condition agrees with the slave address stored in the high-or- der 7 bits of the i 2 c address register (address 002c 16 ). ? a general call is received. in the slave receive mode, when the 10-bit addressing format is selected, this bit is set to 1 with the following condition: ? when the address data is compared with the i 2 c address reg- ister (8 bits consisting of slave address and rbw bit), the first bytes agree. a this bit is set to 0 by executing a write instruction to the i 2 c data shift register (address 002b 16 ) when es0 is set to 1 or reset. ?bit 3: arbitration lost ] detecting flag (al) in the master transmission mode, when the sda is made l by any other device, arbitration is judged to have been lost, so that this bit is set to 1. at the same time, the trx bit is set to 0, so that immediately after transmission of the byte whose arbitration was lost is completed, the mst bit is set to 0. the arbitration lost can be detected only in the master transmission mode. when ar- bitration is lost during slave address transmission, the trx bit is set to 0 and the reception mode is set. consequently, it becomes possible to detect the agreement of its own slave address and ad- dress data transmitted by another master device. ] arbitration lost : the status in which communication as a master is dis- abled. functional description
1-30 3850/3851 group users manual hardware fig. 28 interrupt request signal generating timing fig. 27 structure of i 2 c status register ?bit 6: communication mode specification bit (transfer direc- tion specification bit: trx) this bit decides a direction of transfer for data communication. when this bit is 0, the reception mode is selected and the data of a transmitting device is received. when the bit is 1, the transmis- sion mode is selected and address data and control data are output onto the sda in synchronization with the clock generated on the s cl . this bit is set/reset by software and hardware. about set/reset by hardware is described below. this bit is set to 1 by hardware when all the following conditions are satisfied: ? when als is 0 ? in the slave reception mode or the slave transmission mode ? when the r/w bit reception is 1 this bit is set to 0 in one of the following conditions: ? when arbitration lost is detected. ? when a stop condition is detected. ? when writing 1 to this bit by software is invalid by the start condition duplication preventing function (note) . ? with mst = 0 and when a start condition is detected. ? with mst = 0 and when ack non-return is detected. ? at reset ?bit 7: communication mode specification bit (master/slave specification bit: mst) this bit is used for master/slave specification for data communica- tion. when this bit is 0, the slave is specified, so that a start condition and a stop condition generated by the master are re- ceived, and data communication is performed in synchronization with the clock generated by the master. when this bit is 1, the master is specified and a start condition and a stop condition are generated. additionally, the clocks required for data communi- cation are generated on the scl. this bit is set to 0 in one of the following conditions. ? immediately after completion of 1-byte data transfer when arbi- tration lost is detected ? when a stop condition is detected. ? writing 1 to this bit by software is invalid by the start condi- tion duplication preventing function (note) . ? at reset note: start condition duplication preventing function the mst, trx, and bb bits is set to 1 at the same time after con- firming that the bb flag is 0 in the procedure of a start condition occurrence. however, when a start condition by another master device occurs and the bb flag is set to 1 immediately after the con- tents of the bb flag is confirmed, the start condition duplication preventing function makes the writing to the mst and trx bits in- valid. the duplication preventing function becomes valid from the rising of the bb flag to reception completion of slave address. s cl pin iicirq b7 mst b0 i 2 c status register (s1 : address 002d 16 ) last receive bit (note) 0 : last bit = ?? 1 : last bit = ?? general call detecting flag (note) 0 : no general call detected 1 : general call detected slave address comparison flag (note) 0 : address disagreement 1 : address agreement arbitration lost detecting flag (note) 0 : not detected 1 : detected scl pin low hold bit 0 : scl pin low hold 1 : scl pin low release bus busy flag 0 : bus free 1 : bus busy communication mode specification bits 00 : slave receive mode 01 : slave transmit mode 10 : master receive mode 11 : master transmit mode trx bb pin al aas ad0 lrb note: these bits and flags can be read out, but cannot be written. write ??to these bits at writing. functional description
3850/3851 group users manual hardware 1-31 fig. 31 start/stop condition detecting timing diagram start/stop condition detecting operation the start/stop condition detection operations are shown in figures 28, 29, and table 8. the start/stop condition is set by the start/stop condition set bit. the start/stop condition can be detected only when the input signal of the s cl and s da pins satisfy three conditions: s cl re- lease time, setup time, and hold time (see table 8). the bb flag is set to 1 by detecting the start condition and is reset to 0 by detecting the stop condition. the bb flag set/reset timing is different in the standard clock mode and the high-speed clock mode. refer to table 8, the bb flag set/ reset time. note: when a stop condition is detected in the slave mode (mst = 0), an interrupt request signal iicirq occurs to the cpu. start condition generating method when writing 1 to the mst, trx, and bb bits of the i 2 c status register (address 002d 16 ) at the same time after writing the slave address to the i 2 c data shift register (address 002b 16 ) with the condition in which the es0 bit of the i 2 c control register (address 002e 16 ) is 1 and the bb flag is 0, a start condition occurs. after that, the bit counter becomes 000 2 and an s cl for 1 byte is output. the start condition generating timing is different in the standard clock mode and the high-speed clock mode. refer to figure 26, the start condition generating timing diagram, and table 6, the start condition generating timing table. stop condition generating method when the es0 bit of the i 2 c control register (address 002e 16 ) is 1, write 1 to the mst and trx bits, and write 0 to the bb bit of the i 2 c status register (address 002d 16 ) simultaneously. then a stop condition occurs. the stop condition generating timing is different in the standard clock mode and the high-speed clock mode. refer to figure 27, the stop condition generating timing diagram, and table 7, the stop condition generating timing table. fig. 29 start condition generating timing diagram fig. 30 stop condition generating timing diagram table 9 stop condition generating timing table item setup time hold time standard clock mode 5.0 m s (20 cycles) 4.5 m s (18 cycles) note: absolute time at f = 4 mhz. the value in parentheses denotes the number of f cycles. high-speed clock mode 3.0 m s (12 cycles) 2.5 m s (10 cycles) table 8 start condition generating timing table item setup time hold time standard clock mode 5.0 m s (20 cycles) 5.0 m s (20 cycles) note: absolute time at f = 4 mhz. the value in parentheses denotes the number of f cycles. high-speed clock mode 2.5 m s (10 cycles) 2.5 m s (10 cycles) table 10 start condition/stop condition detecting conditions note: unit : cycle number of system clock f ssc value is the decimal notation value of the start/stop condi- tion set bits ssc4 to ssc0. do not set 0 or an odd number to ssc value. the value in parentheses is an example when the i 2 c start/ stop condition control register is set to 18 16 at f = 4 mhz. fig. 32 stop condition detecting timing diagram s cl release time standard clock mode high-speed clock mode 4 cycles (1.0 m s) 2 cycles (1.0 m s) 2 cycles (0.5 m s) 3.5 cycles (0.875 m s) scc value + 1 2 scc value + 1 2 scc value C1 2 setup time hold time bb flag set/ reset time scc value + 1 cycle (6.25 m s) cycle < 4.0 m s (3.125 m s) cycle < 4.0 m s (3.125 m s) + 2 cycles (3.375 m s) i 2 c status register write signal hold time setup time s cl s da i 2 c status register write signal hold time setup time s cl s da hold time setup time s cl s da bb flag s cl release time bb flag reset time hold time setup time s cl s da bb flag s cl release time bb flag reset time functional description
1-32 3850/3851 group users manual hardware [i 2 c start/stop condition control register (s2d)] 0030 16 the i 2 c start/stop condition control register (address 0030 16 ) controls start/stop condition detection. ?bits 0 to 4: start/stop condition set bit (ssc4Cssc0) scl release time, setup time, and hold time change the detection condition by value of the main clock divide ratio selection bit and the oscillation frequency f(x in ) because these time are measured by the internal system clock. accordingly, set the proper value to the start/stop condition set bits (ssc4 to ssc0) in considered of the system clock frequency. refer to table 8. do not set 00000 2 or an odd number to the start/stop condi- tion set bit (ssc4 to ssc0). refer to table 9, the recommended set value to start/stop condition set bits (ssc4Cssc0) for each oscillation frequency. ?bit 5: scl/sda interrupt pin polarity selection bit (sip) an interrupt can occur when detecting the falling or rising edge of the scl or sda pin. this bit selects the polarity of the scl or sda pin interrupt pin. ?bit 6: scl/sda interrupt pin selection bit (sis) this bit selects the pin of which interrupt becomes valid between the scl pin and the sda pin. note: when changing the setting of the s cl /s da interrupt pin polarity se- lection bit, the s cl /s da interrupt pin selection bit, or the i 2 c-bus interface enable bit es0, the s cl /s da interrupt request bit may be set. when selecting the s cl /s da interrupt source, disable the inter- rupt before the s cl /s da interrupt pin polarity selection bit, the s cl / s da interrupt pin selection bit, or the i 2 c-bus interface enable bit es0 is set. reset the request bit to 0 after setting these bits, and enable the interrupt. address data communication there are two address data communication formats, namely, 7-bit addressing format and 10-bit addressing format. the respective address communication formats are described below. 7-bit addressing format to adapt the 7-bit addressing format, set the 10bit sad bit of the i 2 c control register (address 002e 16 ) to 0. the first 7-bit address data transmitted from the master is compared with the high-order 7-bit slave address stored in the i 2 c address register (address 002c 16 ). at the time of this comparison, address com- parison of the rwb bit of the i 2 c address register (address 002c 16 ) is not performed. for the data transmission format when the 7-bit addressing format is selected, refer to figure 31, (1) and (2). 10-bit addressing format to adapt the 10-bit addressing format, set the 10bit sad bit of the i 2 c control register (address 002e 16 ) to 1. an address comparison is performed between the first-byte address data transmitted from the master and the 8-bit slave address stored in the i 2 c address register (address 002c 16 ). at the time of this comparison, an address comparison between the rwb bit of the i 2 c address register (address 002c 16 ) and the r/w bit which is the last bit of the address data transmitted from the master is made. in the 10-bit addressing mode, the rwb bit which is the last bit of the address data not only specifies the direction of communication for control data, but also is pro- cessed as an address data bit. when the first-byte address data agree with the slave address, the aas bit of the i 2 c status register (address 002d 16 ) is set to 1. after the second-byte address data is stored into the i 2 c data shift register (address 002b 16 ), perform an address com- parison between the second-byte data and the slave address by software. when the address data of the 2 bytes agree with the slave address, set the rbw bit of the i 2 c address register (address 002c 16 ) to 1 by software. this processing can make the 7-bit slave address and r/w data agree, which are re- ceived after a restart condition is detected, with the value of the i 2 c address register (address 002c 16 ). for the data trans- mission format when the 10-bit addressing format is selected, refer to figure 31, (3) and (4). functional description
3850/3851 group users manual hardware 1-33 start/stop condition control register oscillation frequency f(x in ) (mhz) fig. 34 address data communication format fig. 33 structure of i 2 c start/stop condition control register note: do not set an odd number to the start/stop condition set bit (ssc4 to ssc0). table 11 recommended set value to start/stop condition set bits (ssc4Cssc0) for each oscillation frequency main clock divide ratio system clock f (mhz) scl release time ( m s) setup time ( m s) hold time ( m s) 8 8 4 2 2 8 2 2 xxx11010 xxx11000 xxx00100 xxx01100 xxx01010 xxx00100 3.375 m s (13.5 cycles) 3.125 m s (12.5 cycles) 2.5 m s (2.5 cycles) 3.25 m s (6.5 cycles) 2.75 m s (5.5 cycles) 2.5 m s (2.5 cycles) 6.75 m s (27 cycles) 6.25 m s (25 cycles) 5.0 m s (5 cycles) 6.5 m s (13 cycles) 5.5 m s (11 cycles) 5.0 m s (5 cycles) 3.375 m s (13.5 cycles) 3.125 m s (12.5 cycles) 2.5 m s (2.5 cycles) 3.25 m s (6.5 cycles) 2.75 m s (5.5 cycles) 2.5 m s (2.5 cycles) 4 1 2 1 b7 b0 i 2 c start/stop condition control register start/stop condition set bit s cl /s da interrupt pin polarity selection bit 0 : falling edge active 1 : rising edge active s cl /s da interrupt pin selection bit 0 : s da valid 1 : s cl valid reserved do not write ??to this bit. sis sip ssc4 ssc3 ssc2 ssc1 ssc0 (s2d : address 0030 16 ) s slave address r/w a data a/a p a data 7 bits ? 1 to 8 bits 1 to 8 bits (1) a master-transmitter transnmits data to a slave-receiver s slave address r/w a data a p a data 7 bits ? 1 to 8 bits 1 to 8 bits (2) a master-receiver receives data from a slave-transmitter 7 bits ? 8 bits (3) a master-transmitter transmits data to a slave-receiver with a 10-bit address 1 to 8 bits 1 to 8 bits s r/w a slave address 1st 7 bits slave address 2nd bytes a a data data p a/a 7 bits ? 8 bits (4) a master-receiver receives data from a slave-transmitter with a 10-bit address s : start condition a : ack bit sr : restart condition p : stop condition r/w : read/write bit 7 bits ? 1 to 8 bits 1 to 8 bits s r/w a slave address 1st 7 bits slave address 2nd bytes a sr slave address 1st 7 bits r/w a data data p a : master to slave : slave to master a functional description
1-34 3850/3851 group users manual hardware example of master transmission an example of master transmission in the standard clock mode, at the scl frequency of 100 khz and in the ack return mode is shown below. set a slave address in the high-order 7 bits of the i 2 c address register (address 002c 16 ) and 0 into the rwb bit. set the ack return mode and scl = 100 khz by setting 85 16 in the i 2 c clock control register (address 002f 16 ). a set 00 16 in the i 2 c status register (address 002d 16 ) so that transmission/reception mode can become initializing condition. ? set a communication enable status by setting 08 16 in the i 2 c control register (address 002e 16 ). ? confirm the bus free condition by the bb flag of the i 2 c status register (address 002d 16 ). ? set the address data of the destination of transmission in the high-order 7 bits of the i 2 c data shift register (address 002b 16 ) and set 0 in the least significant bit. ? set f0 16 in the i 2 c status register (address 002d 16 ) to gener- ate a start condition. at this time, an scl for 1 byte and an ack clock automatically occur. ? set transmit data in the i 2 c data shift register (address 002b 16 ). at this time, an scl and an ack clock automatically occur. when transmitting control data of more than 1 byte, repeat step ? . set d0 16 in the i 2 c status register (address 002d 16 ) to gener- ate a stop condition if ack is not returned from slave reception side or transmission ends. example of slave reception an example of slave reception in the high-speed clock mode, at the scl frequency of 400 khz, in the ack non-return mode and using the addressing format is shown below. set a slave address in the high-order 7 bits of the i 2 c address register (address 002c 16 ) and 0 in the rwb bit. set the no ack clock mode and scl = 400 khz by setting 65 16 in the i 2 c clock control register (address 002f 16 ). a set 00 16 in the i 2 c status register (address 002d 16 ) so that transmission/reception mode can become initializing condition. ? set a communication enable status by setting 08 16 in the i 2 c control register (address 002e 16 ). ? when a start condition is received, an address comparison is performed. ? ?when all transmitted addresses are 0 (general call): ad0 of the i 2 c status register (address 002d 16 ) is set to 1 and an interrupt request signal occurs. ? when the transmitted addresses agree with the address set in : ass of the i 2 c status register (address 002d 16 ) is set to 1 and an interrupt request signal occurs. ? in the cases other than the above ad0 and aas of the i 2 c sta- tus register (address 002d 16 ) are set to 0 and no interrupt request signal occurs. ? set dummy data in the i 2 c data shift register (address 002b 16 ). ? when receiving control data of more than 1 byte, repeat step ? . when a stop condition is detected, the communication ends. functional description
3850/3851 group users manual hardware 1-35 (2) start condition generating procedure using multi-master 1. procedure example (the necessary conditions of the generat- ing procedure are described as the following 2 to 5. : : lda (taking out of slave address value) sei (interrupt disabled) bbs 5, s1, busbusy (bb flag confirming and branch pro- cess) busfree: sta s0 (writing of slave address value) ldm #$f0, s1 (trigger of start condition generating) cli (interrupt enabled) : : busbusy: cli (interrupt enabled) : : 2. use branch on bit set of bbs 5, $002d, C for the bb flag confirming and branch process. 3. use sta $2b, stx $2b or sty $2b of the zero page ad- dressing instruction for writing the slave address value to the i 2 c data shift register. 4. execute the branch instruction of above 2 and the store instruc- tion of above 3 continuously shown the above procedure example. 5. disable interrupts during the following three process steps: ? bb flag confirming ? writing of slave address value ? trigger of start condition generating when the condition of the bb flag is bus busy, enable interrupts immediately. (3) restart condition generating procedure 1. procedure example (the necessary conditions of the generat- ing procedure are described as the following 2 to 4.) execute the following procedure when the pin bit is 0. : : ldm #$00, s1 (select slave receive mode) lda (t aking out of slave address value) sei (interrupt disabled) sta s0 (writing of slave address value) ldm #$f0, s1 ( trigger of restart condition generating ) cli (interrupt enabled) : : 2. select the slave receive mode when the pin bit is 0. do not write 1 to the pin bit. neither 0 nor 1 is specified for the writing to the bb bit. the trx bit becomes 0 and the s da pin is released. 3. the s cl pin is released by writing the slave address value to the i 2 c data shift register. 4. disable interrupts during the following two process steps: ? writing of slave address value ? trigger of restart condition generating (4) writing to i 2 c status register do not execute an instruction to set the pin bit to 1 from 0 and an instruction to set the mst and trx bits to 0 from 1 simulta- neously. it is because it may enter the state that the s cl pin is released and the s da pin is released after about one machine cycle. do not execute an instruction to set the mst and trx bits to 0 from 1 simultaneously when the pin bit is 1. it is because it may become the same as above. (5) process of after stop condition generating do not write data in the i 2 c data shift register s0 and the i 2 c sta- tus register s1 until the bus busy flag bb becomes 0 after generating the stop condition in the master mode. it is because the stop condition waveform might not be normally generated. reading to the above registers do not have the problem. n precautions when using multi-master i 2 c-bus interface (1) read-modify-write instruction the precautions when the read-modify-write instruction such as seb, clb etc. is executed for each register of the multi-master i 2 c-bus interface are described below. ?i 2 c data shift register (s0: address 002b 16 ) when executing the read-modify-write instruction for this regis- ter during transfer, data may become a value not intended. ?i 2 c address register (s0d: address 002c 16 ) when the read-modify-write instruction is executed for this regis- ter at detecting the stop condition, data may become a value not intended. it is because h/w changes the read/write bit (rbw) at the above timing. ?i 2 c status register (s1: address 002d 16 ) do not execute the read-modify-write instruction for this register because all bits of this register are changed by h/w. ?i 2 c control register (s1d: address 002e 16 ) when the read-modify-write instruction is executed for this regis- ter at detecting the start condition or at completing the byte transfer, data may become a value not intended. because h/w changes the bit counter (bc0-bc2) at the above timing. ?i 2 c clock control register (s2: address 002f 16 ) the read-modify-write instruction can be executed for this regis- ter. ?i 2 c start/stop condition control register (s2d: address 0030 16 ) the read-modify-write instruction can be executed for this regis- ter. functional description
1-36 3850/3851 group users manual hardware pulse width modulation (pwm) the 3851 group has a pwm function with an 8-bit resolution, based on a signal that is the clock input x in or that clock input di- vided by 2. data setting the pwm output pin also functions as port p4 4 . set the pwm pe- riod by the pwm prescaler, and set the h term of output pulse by the pwm register. if the value in the pwm prescaler is n and the value in the pwm register is m (where n = 0 to 255 and m = 0 to 255) : pwm period = 255 5 (n+1) / f(x in ) = 31.875 5 (n+1) m s (when f(x in ) = 8 mhz, count source is f(x in )) output pulse h term = pwm period 5 m / 255 = 0.125 5 (n+1) 5 m m s (when f(x in ) = 8 mhz, count source is f(x in )) fig. 35 timing of pwm period fig. 36 block diagram of pwm function 31.875 5 m 5 (n+1) 255 m s t = [31.875 5 (n+1)] m s pwm output m: contents of pwm register n : contents of pwm prescaler t : pwm period (when f(x in ) = 8 mhz, count source is f(x in )) pwm operation when bit 0 (pwm enable bit) of the pwm control register is set to 1, operation starts by initializing the pwm output circuit, and pulses are output starting at an h. if the pwm register or pwm prescaler is updated during pwm output, the pulses will change in the cycle after the one in which the change was made. data bus count source selection bit ? ? pwm prescaler pre-latch pwm register pre-latch pwm prescaler latch pwm register latch transfer control circuit pwm register 1/2 x in port p4 4 latch pwm enable bit port p4 4 pwm prescaler functional description
3850/3851 group users manual hardware 1-37 fig. 37 structure of pwm control register fig. 38 pwm output timing when pwm register or pwm prescaler is changed pwm control register (pwmcon : address 001d 16 ) pwm function enable bit count source selection bit not used (return ??when read) b7 b0 0: pwm disabled 1: pwm enabled 0: f(x in ) 1: f(x in )/2 abc b t c t2 = pwm output pwm register write signal pwm prescaler write signal (changes ??term from ??to ??) (changes pwm period from ??to ?2?) when the contents of the pwm register or pwm prescaler have changed, the pwm output will change from the next period after the change. t t t2 functional description n note the pwm starts after the pwm enable bit is set to enable and l level is output from the pwm pin. the length of this l level output is as follows: sec (count source selection bit = 0, where n is the value set in the prescaler) sec (count source selection bit = 1, where n is the value set in the prescaler) n+1 2 ? f(x in ) n+1 f(x in )
1-38 3850/3851 group users manual hardware a-d converter [a-d conversion registers (adl, adh)] 0035 16 , 0036 16 the a-d conversion registers are read-only registers that store the result of an a-d conversion. do not read these registers during an a-d conversion [ad control register (adcon)] 0034 16 the ad control register controls the a-d conversion process. bits 0 to 2 select a specific analog input pin. bit 4 indicates the completion of an a-d conversion. the value of this bit remains at 0 during an a-d conversion and changes to 1 when an a-d conversion ends. writing 0 to this bit starts the a-d conversion. comparison voltage generator the comparison voltage generator divides the voltage between av ss and v ref into 1024 and outputs the divided voltages. channel selector the channel selector selects one of ports p3 0 /an 0 to p3 4 /an 4 and inputs the voltage to the comparator. comparator and control circuit the comparator and control circuit compare an analog input volt- age with the comparison voltage, and the result is stored in the a-d conversion registers. when an a-d conversion is completed, the control circuit sets the a-d conversion completion bit and the a-d interrupt request bit to 1. note that because the comparator consists of a capacitor cou- pling, set f(x in ) to 500 khz or more during an a-d conversion. the m38514e6/m6 can operate at even low-speed mode, be- cause of the a-d converter of the m38514e6/m6 has a built-in self-oscillation circuit. fig. 39 structure of ad control register fig. 40 structure of a-d conversion registers ad control register (adcon : address 0034 16 ) analog input pin selection bits 0 0 0: p3 0 /an 0 0 0 1: p3 1 /an 1 0 1 0: p3 2 /an 2 0 1 1: p3 3 /an 3 1 0 0: p3 4 /an 4 not used (returns ??when read) a-d conversion completion bit 0: conversion in progress 1: conversion completed not used (returns ??when read) b7 b0 b2 b1 b0 10-bit reading (read address 0036 16 before 0035 16 ) (address 0036 16 ) (address 0035 16 ) 8-bit reading (read only address 0035 16 ) (address 0035 16 ) b8 b7 b6 b5 b4 b3 b2 b1 b0 b7 b0 b9 b7 b0 note : the high-order 6 bits of address 0036 16 become ? at reading. b9 b8 b7 b6 b5 b4 b3 b2 b7 b0 channel selector a-d control circuit a-d conversion low-order register resistor ladder v ref av ss comparator a-d conversion interrupt request b7 b0 3 10 p3 0 /an 0 p3 1 /an 1 p3 2 /an 2 p3 3 /an 3 p3 4 /an 4 data bus ad control register a-d conversion high-order register (address 0034 16 ) (address 0036 16 ) (address 0035 16 ) fig. 41 block diagram of a-d converter functional description
3850/3851 group users manual hardware 1-39 watchdog timer the watchdog timer gives a mean of returning to the reset status when a program cannot run on a normal loop (for example, be- cause of a software run-away). the watchdog timer consists of an 8-bit watchdog timer l and an 8-bit watchdog timer h. standard operation of watchdog timer when any data is not written into the watchdog timer control reg- ister (address 0039 16 ) after resetting, the watchdog timer is in the stop state. the watchdog timer starts to count down by writing an optional value into the watchdog timer control register (address 0039 16 ) and an internal reset occurs at an underflow of the watch- dog timer h. accordingly, programming is usually performed so that writing to the watchdog timer control register (address 0039 16 ) may be started before an underflow. when the watchdog timer control reg- ister (address 0039 16 ) is read, the values of the high-order 6 bits of the watchdog timer h, stp instruction disable bit, and watch- dog timer h count source selection bit are read. l initial value of watchdog timer at reset or writing to the watchdog timer control register (address 0039 16 ), each watchdog timer h and l is set to ff 16 . fig. 43 structure of watchdog timer control register l watchdog timer h count source selection bit operation bit 7 of the watchdog timer control register (address 0039 16 ) per- mits selecting a watchdog timer h count source. when this bit is set to 0, the count source becomes the underflow signal of watchdog timer l. the detection time is set to 131.072 ms at f(x in ) = 8 mhz frequency and 32.768 s at f(x cin ) = 32 khz frequency. when this bit is set to 1, the count source becomes the signal divided by 16 for f(x in ) (or f(x cin )). the detection time in this case is set to 512 m s at f(x in ) = 8 mhz frequency and 128 ms at f(x cin ) = 32 khz frequency. this bit is cleared to 0 after resetting. l operation of stp instruction disable bit bit 6 of the watchdog timer control register (address 0039 16 ) per- mits disabling the stp instruction when the watchdog timer is in operation. when this bit is 0, the stp instruction is enabled. when this bit is 1, the stp instruction is disabled, once the stp instruction is executed, an internal reset occurs. when this bit is set to 1, it cannot be rewritten to 0 by program. this bit is cleared to 0 after resetting. fig. 42 block diagram of watchdog timer x in data bus x cin ?0 ?0 ?1 main clock division ratio selection bits (note) ? ? 1/16 watchdog timer h count source selection bit reset circuit stp instruction disable bit watchdog timer h (8) ?f 16 ?is set when watchdog timer control register is written to. internal reset reset watchdog timer l (8) note: any one of high-speed, middle-speed or low-speed mode is selected by bits 7 and 6 of the cpu mode register. stp instruction ?f 16 ?is set when watchdog timer control register is written to. b0 stp instruction disable bit 0: stp instruction enabled 1: stp instruction disabled watchdog timer h count source selection bit 0: watchdog timer l underflow 1: f(x in )/16 or f(x cin )/16 watchdog timer h (for read-out of high-order 6 bit) watchdog timer control register (wdtcon : address 0039 16 ) b7 functional description
1-40 3850/3851 group users manual hardware reset circuit to reset the microcomputer, reset pin must be held at an "l" level for 2 m s or more. then the reset pin is returned to an "h" level (the power source voltage must be between 2.7 v and 5.5 v, and the oscillation must be stable), reset is released. after the re- set is completed, the program starts from the address contained in address fffd 16 (high-order byte) and address fffc 16 (low-order byte). make sure that the reset input voltage is less than 0.54 v for v cc of 2.7 v. fig. 45 reset sequence fig. 44 reset circuit example (note) 0.2v cc 0v 0v poweron v cc reset v cc reset power source voltage detection circuit power source voltage reset input voltage note : reset release voltage ; vcc=2.7 v reset data f address sync x in : 8 to 13 clock cycles x in ? ? ? ? ? fffc fffd ad h , l ? ? ? ? ? ad l ad h 1: the frequency relation of f(x in ) and f( f ) is f(x in ) = 2 f( f ). 2: the question marks (?) indicate an undefined state that depends on the previous state. 3: all signals except x in and reset are internals. reset address from the vector table. notes reset out functional description
3850/3851 group users manual hardware 1-41 fig. 46 internal status at reset port p0 direction register (p0d) port p1 direction register (p1d) port p2 direction register (p2d) port p3 direction register (p3d) port p4 direction register (p4d) serial i/o status register (siosts) serial i/o control register (siocon) uart control register (uartcon) pwm control register (pwmcon) prescaler 12 (pre12) timer 1 (t1) timer 2 (t2) timer xy mode register (tm) prescaler x (prex) timer x (tx) prescaler y (prey) timer y (ty) timer count source select register i 2 c address register (s0d) i 2 c status register (s1) i 2 c control register (s1d) i 2 c clock control register (s2) i 2 c start/stop condition control register (s2d) ad control register (adcon) misrg watchdog timer control register (wdtcon) interrupt edge selection register (intedge) cpu mode register (cpum) interrupt request register 1 (ireq1) interrupt request register 2 (ireq2) interrupt control register 1 (icon1) interrupt control register 2 (icon2) processor status register program counter (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) (24) (25) (26) (27) (28) (29) (30) (31) (32) (33) (34) note : x indicates not fixed . address register contents 0001 16 0003 16 0005 16 0007 16 0009 16 0019 16 001a 16 001b 16 001d 16 0020 16 0021 16 0022 16 0023 16 0024 16 0025 16 0026 16 0027 16 0028 16 002c 16 002d 16 002e 16 002f 16 0030 16 0034 16 0038 16 0039 16 003a 16 003b 16 003c 16 003d 16 003e 16 003f 16 (ps) (pc h ) (pc l ) 00 16 00 16 00 16 00 16 00 16 00 16 00 16 ff 16 01 16 00 16 00 16 ff 16 ff 16 ff 16 ff 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 0001000x 0 00xxxxx 10000000 11100000 1 01001 0 0 xx xx xx x 00010000 00111111 0 fffd 16 contents fffc 16 contents functional description
1-42 3850/3851 group users manual hardware clock generating circuit the 3851 group has two built-in oscillation circuits. an oscillation circuit can be formed by connecting a resonator between x in and x out (x cin and x cout ). use the circuit constants in accordance with the resonator manufacturers recommended values. no exter- nal resistor is needed between x in and x out since a feed-back resistor exists on-chip. however, an external feed-back resistor is needed between x cin and x cout . immediately after power on, only the x in oscillation circuit starts oscillating, and x cin and x cout pins function as i/o ports. frequency control (1) middle-speed mode the internal clock f is the frequency of x in divided by 8. after re- set, this mode is selected. (2) high-speed mode the internal clock f is half the frequency of x in . (3) low-speed mode the internal clock f is half the frequency of x cin . n note if you switch the mode between middle/high-speed and low- speed, stabilize both x in and x cin oscillations. the sufficient time is required for the sub-clock to stabilize, especially immediately af- ter power on and at returning from the stop mode. when switching the mode between middle/high-speed and low-speed, set the fre- quency on condition that f(x in ) > 3?f(x cin ). (4) low power dissipation mode the low power consumption operation can be realized by stopping the main clock x in in low-speed mode. to stop the main clock, set bit 5 of the cpu mode register to 1. when the main clock x in is restarted (by setting the main clock stop bit to 0), set sufficient time for oscillation to stabilize. the sub-clock x cin -x cout oscillating circuit can not directly input clocks that are generated externally. accordingly, make sure to cause an external resonator to oscillate. oscillation control (1) stop mode if the stp instruction is executed, the internal clock f stops at an h level, and x in and x cin oscillation stops. when the oscillation stabilizing time set after stp instruction released bit is 0, the prescaler 12 is set to ff 16 and timer 1 is set to 01 16 . when the oscillation stabilizing time set after stp instruction released bit is 1, set the sufficient time for oscillation of used oscillator to stabi- lize since nothing is set to the prescaler 12 and timer 1. either x in or x cin divided by 16 is input to the prescaler 12 as count source. oscillator restarts when an external interrupt is re- ceived, but the internal clock f is not supplied to the cpu (remains at h) until timer 1 underflows. the internal clock f is supplied for the first time, when timer 1 underflows. this ensures time for the clock oscillation using the ceramic resonators to be stabilized. when the oscillator is restarted by reset, apply l level to the reset pin until the oscillation is stable since a wait time will not fig. 47 ceramic resonator circuit fig. 48 external clock input circuit x cin x cout x in x out c in c out c cin c cout rf rd x cin x cout x in x out c cin c cout rf rd open external oscillation circuit vcc vss be generated. (2) wait mode if the wit instruction is executed, the internal clock f stops at an h level, but the oscillator does not stop. the internal clock f re- starts at reset or when an interrupt is received. since the oscillator does not stop, normal operation can be started immediately after the clock is restarted. to ensure that the interrupts will be received to release the stp or wit state, their interrupt enable bits must be set to 1 before ex- ecuting of the stp or wit instruction. when releasing the stp state, the prescaler 12 and timer 1 will start counting the clock xin divided by 16. accordingly, set the timer 1 interrupt enable bit to 0 before executing the stp instruc- tion. n note when using the oscillation stabilizing time set after stp instruction released bit set to 1, evaluate time to stabilize oscillation of the used oscillator and set the value to the timer 1 and prescaler 12. functional description
3850/3851 group users manual hardware 1-43 fig. 50 system clock generating circuit block diagram (single-chip mode) wit instruction stp instruction timing f (internal clock) s r q stp instruction s r q main clock stop bit s r q 1/2 1/4 x in x out x cout x cin interrupt request reset interrupt disable flag l 1/2 port x c switch bit ? ? low-speed mode high-speed or middle-speed mode middle-speed mode high-speed or low-speed mode main clock division ratio selection bits (note 1) notes 1: any one of high-speed, middle-speed or low-speed mode is selected by bits 7 and 6 of the cpu mode register. when low-speed mode is selected, set port xc switch bit (b1) to ?? 2: when the oscillation stabilizing time set after stp instruction released bit is ?? main clock division ratio selection bits (note 1) ff 16 01 16 prescaler 12 timer 1 reset or stp instruction (note 2) functional description misrg (misrg : address 0038 16 ) oscillation stabilizing time set after stp instruction released bit middle-speed mode automatic switch set bit middle-speed mode automatic switch wait time set bit middle-speed mode automatic switch start bit (depending on program) not used (return ??when read) b7 b0 0: automatically set 01 16 ?to timer 1, ?f 16 ?to prescaler 12 1: automatically set nothing 0: not set automatically 1: automatic switching enable 0: 4.5 to 5.5 machine cycles 1: 6.5 to 7.5 machine cycles 0: invalid 1: automatic switch start fig. 49 structure of misrg middle-speed mode automatic switch set bit by setting the middle-speed mode automatic switch set bit to 1 while operating in the low-speed mode, x in oscillation automati- cally starts and the mode is automatically switched to the middle-speed mode when defecting a rising/falling edge of the s cl or s da pin. the middle-speed automatic switch wait time set bit can select the switch timing from the low-speed to the middle- speed mode; either 4.5 to 5.5 machine cycles or 6.5 to 7.5 machine cycles in the low-speed mode. select it according to os- cillation start characteristics of used x in oscillator. the middle-speed mode automatic switch start bit is used to auto- matically make to x in oscillation start and switch to the middle-speed mode by setting this bit to 1 while operating in the low-speed mode.
1-44 3850/3851 group users manual hardware fig. 51 state transitions of system clock cm 4 : port xc switch bit 0 : i/o port function (stop oscillating) 1 : x cin -x cout oscillating function cm 5 : main clock (x in - x out ) stop bit 0 : oscillating 1 : stopped cm 7 , cm 6 : main clock division ratio selection bit b7 b6 0 0 : f = f(x in )/2 ( high-speed mode) 0 1 : f = f(x in )/8 (middle-speed mode) 1 0 : f = f(x cin )/2 (low-speed mode) 1 1 : not available notes reset cm 4 1 ?? 0 cm 4 0 ?? 1 cm 6 1 ?? 0 cm 4 1 ?? 0 cm 6 1 ?? 0 cm 7 1 ?? 0 cm 4 1 ?? 0 cm 5 1 ?? 0 cm 6 1 ?? 0 cm 6 1 ?? 0 cpu mode register b7 b4 cm 7 0 ?? 1 cm 6 1 ?? 0 (cpum : address 003b 16 ) cm 7 =0 cm 6 =1 cm 5 =0(8 mhz oscillating) cm 4 =0(32 khz stopped) middle-speed mode (f( f )=1 mhz) cm 7 =0 cm 6 =1 cm 5 =0(8 mhz oscillating) cm 4 =1(32 khz oscillating) middle-speed mode (f( f )=1 mhz) cm 7 =0 cm 6 =0 cm 5 =0(8 mhz oscillating) cm 4 =0(32 khz stopped) high-speed mode (f( f )=4 mhz) cm 7 =1 cm 6 =0 cm 5 =0(8 mhz oscillating) cm 4 =1(32 khz oscillating) low-speed mode (f( f )=16 khz) cm 7 =1 cm 6 =0 cm 5 =1(8 mhz stopped) cm 4 =1(32 khz oscillating) low-speed mode (f( f )=16 khz) cm 7 =0 cm 6 =0 cm 5 =0(8 mhz oscillating) cm 4 =1(32 khz oscillating) high-speed mode (f( f )=4 mhz) 1 : switch the mode by the allows shown between the mode blocks. (do not switch between the modes directly without an allow.) 2 : the all modes can be switched to the stop mode or the wait mode and return to the source mode when the stop mode or the wait mo de is ended. 3 : timer operates in the wait mode. 4 : when the stop mode is ended, a delay of approximately 1 ms occurs by connecting prescaler 12 in middle/high-speed mode. 5 : when the stop mode is ended, a delay of approximately 16 ms occurs by timer 1 and timer 2 in low-speed mode. 6 : wait until oscillation stabilizes after oscillating the main clock x in before the switching from the low-speed mode to middle/high-speed mode. 7 : the example assumes that 8 mhz is being applied to the x in pin and 32 khz to the x cin pin. f indicates the internal clock. functional description
3850/3851 group users manual hardware 1-45 notes on programming processor status register the contents of the processor status register (ps) after a reset are undefined, except for the interrupt disable flag (i) which is 1. after a reset, initialize flags which affect program execution. in particu- lar, it is essential to initialize the index x mode (t) and the decimal mode (d) flags because of their effect on calculations. interrupts the contents of the interrupt request bits do not change immedi- ately after they have been written. after writing to an interrupt request register, execute at least one instruction before performing a bbc or bbs instruction. decimal calculations ? to calculate in decimal notation, set the decimal mode flag (d) to 1, then execute an adc or sbc instruction. after executing an adc or sbc instruction, execute at least one instruction be- fore executing a sec, clc, or cld instruction. ? in decimal mode, the values of the negative (n), overflow (v), and zero (z) flags are invalid. timers if a value n (between 0 and 255) is written to a timer latch, the fre- quency division ratio is 1/(n+1). multiplication and division instructions ? the index x mode (t) and the decimal mode (d) flags do not af- fect the mul and div instruction. ? the execution of these instructions does not change the con- tents of the processor status register. ports the contents of the port direction registers cannot be read. the following cannot be used: ? the data transfer instruction (lda, etc.) ? the operation instruction when the index x mode flag (t) is 1 ? the addressing mode which uses the value of a direction regis- ter as an index ? the bit-test instruction (bbc or bbs, etc.) to a direction register ? the read-modify-write instructions (ror, clb, or seb, etc.) to a direction register. use instructions such as ldm and sta, etc., to set the port direc- tion registers. serial i/o in clock synchronous serial i/o, if the receive side is using an ex- ternal clock and it is to output the s rdy signal, set the transmit enable bit, the receive enable bit, and the s rdy output enable bit to 1. serial i/o continues to output the final bit from the t x d pin after transmission is completed. when an external clock is used as synchronous clock in serial i/o, write transmission data to the transmit buffer register while the transfer clock is h. a-d converter the comparator uses internal capacitors whose charge will be lost if the clock frequency is too low. therefore, make sure that f(x in ) is at least on 500 khz during an a-d conversion. do not execute the stp or wit instruction during an a-d conver- sion. instruction execution time the instruction execution time is obtained by multiplying the fre- quency of the internal clock f by the number of cycles needed to execute an instruction. the number of cycles required to execute an instruction is shown in the list of machine instructions. the frequency of the internal clock f is half of the x in frequency in high-speed mode. notes on programming
1-46 3850/3851 group users manual hardware data required for mask orders the following are necessary when ordering a mask rom produc- tion: 1.mask rom order confirmation form 2.mark specification form 3.data to be written to rom, in eprom form (three identical cop- ies) data required for rom writing orders the following are necessary when ordering a rom writing: 1.rom writing confirmation form 2.mark specification form 3.data to be written to rom, in eprom form (three identical copies) rom programming method the built-in prom of the blank one time prom version and built- in eprom version can be read or programmed with a general-purpose prom programmer using a special programming adapter. set the address of prom programmer in the user rom area. fig. 52 programming and testing of one time prom version table 12 programming adapter package 42p2r-a 42p4b name of programming adapter pca4738f-42a pca4738s-42a the prom of the blank one time prom version is not tested or screened in the assembly process and following processes. to en- sure proper operation after programming, the procedure shown in figure 52 is recommended to verify programming. programming with prom programmer screening (caution) (150 c for 40 hours) verification with prom programmer functional check in target device the screening temperature is far higher than the storage temperature. never expose to 150 c exceeding 100 hours. caution : data required for mask orders/rom programming method
3850/3851 group users manual hardware 1-47 functional description supplement interrupt 3851 group permits interrupts on the basis of 15 sources. it is vec- tor interrupts with a fixed priority system. accordingly, when two or more interrupt requests occur during the same sampling, the higher-priority interrupt is accepted first. this priority is determined by hardware, but variety of priority processing can be performed by software, using an interrupt enable bit and an interrupt disable flag. for interrupt sources, vector addresses and interrupt priority, refer to table 13. vector addresses fffd 16 fffb 16 fff9 16 fff7 16 fff5 16 fff3 16 fff1 16 ffef 16 ffed 16 ffeb 16 ffe9 16 ffe7 16 ffe5 16 ffe3 16 ffe1 16 ffdf 16 ffdd 16 fffc 16 fffa 16 fff8 16 fff6 16 fff4 16 fff2 16 fff0 16 ffee 16 ffec 16 ffea 16 ffe8 16 ffe6 16 ffe4 16 ffe2 16 ffe0 16 ffde 16 ffdc 16 table 13 interrupt sources, vector addresses and interrupt priority high-order low-order priority 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 interrupt sources reset (note 1) int 0 interrupt scl, sda int 1 interrupt int 2 interrupt int 3 interrupt i 2 c interrupt timer x interrupt timer y interrupt timer 1 interrupt timer 2 interrupt serial i/o receive interrupt serial i/o transmit interrupt cntr 0 interrupt cntr 1 interrupt a-d conversion interrupt brk instruction interrupt remarks non-maskable external interrupt (active edge selectable) external interrupt (active edge selectable) external interrupt (active edge selectable) external interrupt (active edge selectable) external interrupt (active edge selectable) stp instruction release timer underflow valid when serial i/o is selected valid when serial i/o is selected external interrupt (active edge selectable) external interrupt (active edge selectable) non-maskable software interrupt note : reset functions in the same way as an interrupt with the highest priority. functional description supplement
1-48 3850/3851 group users manual hardware timing after interrupt the interrupt processing routine begins with the machine cycle fol- lowing the completion of the instruction that is currently in execution. figure 53 shows a timing chart after an interrupt occurs, and fig- ure 54 shows the time up to execution of the interrupt processing routine. fig. 53 timing chart after an interrupt occurs fig. 54 time up to execution of the interrupt processing routine : cpu operation code fetch cycle : vector address of each interrupt : jump destination address of each interrupt : ?0 16 ?or ?1 16 (all signals are internals.) sync b l , b h a l , a h sps data bus not used pc h pc l ps a l a h address bus s, sps s-2, sps s-1, sps pc b l b h a l , a h sync rd wr f functional description supplement generation of interrupt request main routine interrupt processing routine 7 to 23 cycles (at performing 8.0 mhz, in high-speed mode, 1.75 m s to 5.75 m s) 2 cycles 5 cycles start of interrupt processing 0 to 16 cycles waiting time for post-processing of pipeline stack push and vector fetch ] ] : when executing the div instruction
3850/3851 group users manual hardware 1-49 a-d converter a-d conversion is started by setting ad conversion completion bit to 0. during a-d conversion, internal operations are performed as follows. 1. after the start of a-d conversion, a-d conversion register goes to 0016. 2. the highest-order bit of a-d conversion register is set to 1. and the comparison voltage vref is input to the comparator. then, vref is compared with analog input voltage vin. 3. as a result of comparison, when vref < vin, the highest- order bit of a-d conversion register be- comes 1. when vref > vin, the highest-order bit becomes 0. by repeating the above operations up to the lowest-order bit of the a-d conversion register, an analog value converts into a digital value. a-d conversion completes at 61 clock cycles (15.25 m s at f(xin) = 8.0 mhz) after it is started, and the result of the conversion is stored into the a-d conversion register. concurrently with the completion of a-d conversion, the a-d con- version completion bit is set to 1 and an a-d conversion interrupt request occurs, so that the ad conversion interrupt request bit is set to 1. relative formula for a reference voltage v ref of a-d converter and vref when n = 0 vref = 0 when n = 1 to 1023 vref = 5 n n : the value of a-d converter (decimal numeral) v ref 1024 ] 1C ] 10: a result of the first to tenth comparison table 14 change of a-d conversion register during a-d conversion at start of conversion first comparison second comparison third comparison after completion of tenth comparison 100000 1000000 10000000 00000 0 0 0 v ref 2 v ref 4 v ref 2 28 4 v ref v ref v ref a result of a-d conversion ] 1 ] 1 ] 2 ]] ] ]]]] ] 12345678 change of a-d conversion register value of comparison voltage (vref) 00 0 00 00 00 ] 9 ] 10 2 1024 4 v ref v ref v ref ??? ? ? ? ? ? ? ? ? ? functional description supplement
1-50 3850/3851 group users manual hardware figure 55 shows a-d conversion equivalent circuit, and figure 56 shows a-d conversion timing chart. fig. 55 a-d conversion equivalent circuit fig. 56 a-d conversion timing chart v ss v cc av ss v cc v ref av ss a-d control register built-in d-a converter v ref reference clock a-d conversion low-order register a-d converter interrupt request chopper amplifier sampling clock v in an 0 an 1 an 3 c b1 b2 b0 an 2 an 4 approximately 2 k w b4 a-d conversion high-order register write signal for a-d control register ad conversion completion bit sampling clock 61 cycles f functional description supplement
3850/3851 group users manual hardware 1-51 misrg (1) oscillation stabilizing time set after stp instruction released bit (bit 0 of address 0038 16 ) usually, when the mcu stops the clock oscillation by the stp in- struction and the stp instruction has been released by an external interrupt source, the fixed values of timer 1 and prescaler 12 (timer 1 = 01 16 , prescaler 12 = ff 16 ) are automati- cally reloaded in order for the oscillation to stabilize. the user can inhibit the automatic setting by writing 1 to bit 0 of misrg (ad- dress 0038 16 ). however, by setting this bit to 1, the previous values, set just be- fore the stp instruction was executed, will remain in timer 1 and prescaler 12. therefore, you will need to set an appropriate value to each register, in accordance with the oscillation stabilizing time, before executing the stp instruction. figure 57 shows the structure of misrg. (2) middle-speed mode automatic switch function in order to switch the clock mode of an mcu which has a subclock, the following procedure is necessary: set cpu mode register (003b 16 ) --> start main clock oscillation --> wait for oscillation stabilization --> switch to middle-speed mode (or high-speed mode). however, the 3851 group has the built-in function which automati- cally switches from low to middle-speed mode either by the scl/ sda interrupt or by program. figure 58 shows the structure of the i 2 c start/stop condition con- trol register. ? middle-speed mode automatic switch by scl/sda interrupt the scl/sda interrupt source enables an automatic switch when the middle-speed mode automatic switch set bit (bit 1) of misrg (address 0038 16 ) is set to 1. the conditions for an au- tomatic switch execution depend on the settings of bits 5 and 6 of the i 2 c start/stop condition control register (address 0030 16 ). bit 5 is the scl/sda interrupt pin polarity selection bit and bit 6 is the scl/sda interrupt pin selection bit. the main clock oscil- lation stabilizing time can also be selected by middle-speed mode automatic switch wait time set bit (bit 2) of the misrg. ? middle-speed mode automatic switch by program the middle-speed mode can also be automatically switched by program while operating in low-speed mode. by setting the middle-speed automatic switch start bit (bit 3) of misrg (ad- dress 0038 16 ) to 1 while operating in low-speed mode, the mcu will automatically switch to middle-speed mode. in this case, the oscillation stabilizing time of the main clock can be se- lected by the middle-speed automatic switch wait set bit (bit 2) of misrg (address 0038 16 ). functional description supplement
1-52 3850/3851 group users manual hardware functional description supplement fig. 57 structure of misrg b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. 5 misrg oscillation stabilization time set bit after release of the stp instruction 0 0 : set automatically (note 1) 1 : not set automatically 0 0 0 5 5 5 misrg [address : 38 ] 16 0 : not set automatically 1 : automatic switching enable (notes 2, 3) middle-speed mode automatic switch set bit middle-speed mode automatic switch wait time set bit 0 : 4.5 to 5.5 machine cycles 1 : 6.5 to 7.5 machine cycles middle-speed mode automatic switch start bit (depending on program) notes 1: automatically set 01 16 to timer 1, and ff 16 to priscaler 12. 2: during operation in low-speed mode, it is possible automatically to switch to middle-speed mode owing to s cl /s da interrupt. 3: when automatic switch to middle-speed mode from low-speed mode occurs, the values of cpu mode register (3b 16 ) change. 0 : invalid 1 : automatic switch start (note 3) b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 2 3 4 5 6 7 name 0 i 2 c start/stop condition control register (s2d) [address : 30 16 ] i 2 c start/stop condition control register 0 ? 1 start/stop condition set bit (ssc0, ssc1, ssc2, ssc3, ssc4) ( note ) 0 : falling edge active 1 : rising edge active s cl /s da interrupt pin polarity selection bit (sip) s cl /s da interrupt pin select on bit (sis) s cl release time = f ( m s) 5 5 5 (ssc+1) set up time = f ( m s) (ssc+1)/2 hold time = f ( m s) (ssc+1)/2 0 : s da valid 1 : s cl valid fix this bit to 0. 0 note : fix ssc0 bit to 0. fig. 58 structure of i 2 c start/stop condition control register
3850/3851 group users manual hardware 1-53 functional description supplement 3850 group differences between 3850 and 3851 groups 3850 group mcus do not have the built-in i 2 c-bus as in the 3851 group. accordingly, the 3850 group does not have registers relevent to i 2 c-bus interface for the sfr area. the structure of the interrupt control registers also differs. the following is a list of reg- isters which are not included in the 3850 group. (1) i 2 c data shift register (address 002b 16 ) (2) i 2 c address register (address 002c 16 ) (3) i 2 c status register (address 002d 16 ) (4) i 2 c control register (address 002e 16 ) fix es0 bit (bit3) to 0. (5) i 2 c clock control register (address 002f 16 ) (6) i 2 c start/stop condition control register (address 0030 16 ) (7) scl/sda interrupt request bit (bit1) of interrupt request register 1 (address 003c 16 ) (8) i 2 c interrupt request bit (bit5) of interrupt request register 1 (address 003c 16 ) (9) scl/sda interrupt enable bit (bit1) of interrupt control register 1 (address 003e 16 ) fix this bit to 0. (10) i 2 c interrupt enable bit (bit5) of interrupt control register 1 (address 003e 16 ) fix this bit to 0. 48k rom size (bytes) 32k 28k 24k 20k 16k 12k 8k 128 192 256 ram size (bytes) 384 512 640 768 896 1024 m38503m4/e4 under development m38504m6/e6 mass production m38503m2 mass production fig. 59 memory expansion plan of 3850 group
1-54 3850/3851 group users manual hardware functional description supplement interrupt control register 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt control register 1 (icon1) [address : 3e 16 ] int 0 interrupt enable bit fix this bit to 0. 0 : interrupt disabled 1 : interrupt enabled fix this bit to 0. timer x interrupt enable bit int 1 interrupt enable bit int 2 interrupt enable bit int 3 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled timer y interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled fig. 61 structure of interrupt control register 1 of 3850 group interrupt request register 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt request register 1 (ireq1) [address : 3c 16 ] int 0 interrupt request bit fix this bit to 0. 0 : no interrupt request issued 1 : interrupt request issued timer x interrupt request bit ] : these bits can be cleared to 0 by program, but cannot be set to 1. int 1 interrupt request bit int 2 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued int 3 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued ] ] ] ] ] ] ] timer y interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued ] fix this bit to 0. fig. 60 structure of interrupt request register 1 of 3850 group
chapter 2 chapter 2 application 2.1 i/o port 2.2 timer 2.3 serial i/o 2.4 multi-master i 2 c-bus interface 2.5 pwm 2.6 a-d converter 2.7 reset
3850/3851 group users manual application 2.1 i/o port 2-2 2.1 i/o port this paragraph explains the registers setting method and the notes relevant to the i/o ports. 2.1.1 memory map fig. 2.1.1 memory map of registers relevant to i/o port 2.1.2 relevant registers 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 port p0 (p0) port p0 direction register (p0d) port p1 (p1) port p1 direction register (p1d) port p2 (p2) port p2 direction register (p2d) port p3 (p3) port p3 direction register (p3d) 0008 16 0009 16 port p4 direction register (p4d) port p4 (p4) port pi b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name port pi 0 port pi 1 port pi 2 port pi 3 port pi 4 port pi 5 port pi 6 port pi 7 in output mode write read l port latch in input mode write : port latch read : value of pins l port pi (pi) (i = 0, 1, 2, 3, 4) [address : 00 16 , 02 16 , 04 16 , 06 16, 08 16 ] ? ? ? ? ? ? ? ? fig. 2.1.2 structure of port pi (i = 0, 1, 2, 3, 4)
3850/3851 group users manual application 2-3 2.1 i/o port port pi direction register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name port pi direction register 0 0 0 0 0 0 0 0 port pi direction register (pid) (i = 0, 1, 2, 3, 4) [address : 01 16 , 03 16 , 05 16 , 07 16, 09 16 ] 0 : port pi 0 input mode 1 : port pi 0 output mode 0 : port pi 1 input mode 1 : port pi 1 output mode 0 : port pi 2 input mode 1 : port pi 2 output mode 0 : port pi 3 input mode 1 : port pi 3 output mode 0 : port pi 4 input mode 1 : port pi 4 output mode 0 : port pi 5 input mode 1 : port pi 5 output mode 0 : port pi 6 input mode 1 : port pi 6 output mode 0 : port pi 7 input mode 1 : port pi 7 output mode 5 5 5 5 5 5 5 5 fig. 2.1.3 structure of port pi direction register (i=0, 1, 2, 3, 4) 2.1.3 handling of unused pins table 2.1.1 handling of unused pins pins/ports name p0, p1, p2, p3, p4 v ref av ss x out handling ?set to the input mode and connect each to vcc or vss through a resistor of 1 k w to 10 k w . ?set to the output mode and open at l or h level. ?connect to vss (gnd). ?connect to vss (gnd). ?open, only when using an external clock
3850/3851 group users manual application 2.1 i/o port 2-4 2.1.4 notes on input and output pins (1) notes in stand-by state in stand-by state* 1 for low-power dissipation, do not make input levels of an input port and an i/o port undefined, especially for i/o ports of the p-channel and the n-channel open-drain. pull-up (connect the port to v cc ) or pull-down (connect the port to v ss ) these ports through a resistor. when determining a resistance value, note the following points: ? external circuit ? variation of output levels during the ordinary operation l reason even when setting as an output port with its direction register, in the following state : ? p-channel ...... when the content of the port latch is 0 ? n-channel ...... when the content of the port latch is 1 the transistor becomes the off state, which causes the ports to be the high-impedance state. note that the level becomes undefined depending on external circuits. accordingly, the potential which is input to the input buffer in a microcomputer is unstable in the state that input levels of a input port and an i/o port are undefined. this may cause power source current. * 1 stand-by state : the stop mode by executing the stp instruction the wait mode by executing the wit instruction (2) modifying output data with bit managing instruction when the port latch of an i/o port is modified with the bit managing instruction* 2 , the value of the unspecified bit may be changed. l reason the bit managing instructions are read-modify-write form instructions for reading and writing data by a byte unit. accordingly, when these instructions are executed on a bit of the port latch of an i/o port, the following is executed to all bits of the port latch. ? as for a bit which is set for an input port : the pin state is read in the cpu, and is written to this bit after bit managing. ? as for a bit which is set for an output port : the bit value of the port latch is read in the cpu, and is written to this bit after bit managing. note the following : ? even when a port which is set as an output port is changed for an input port, its port latch holds the output data. ? as for a bit of the port latch which is set for an input port, its value may be changed even when not specified with a bit managing instruction in case where the pin state differs from its port latch contents. * 2 bit managing instructions : seb , and clb instructions
3850/3851 group users manual application 2-5 2.1 i/o port 2.1.5 termination of unused pins (1) terminate unused pins output ports : open input ports : connect each pin to v cc or v ss through each resistor of 1 k w to 10 k w . as for pins whose potential affects to operation modes such as pins cnv ss , int or others, select the v cc pin or the v ss pin according to their operation mode. a i/o ports : ? set the i/o ports for the input mode and connect them to v cc or v ss through each resistor of 1 k w to 10 k w . set the i/o ports for the output mode and open them at l or h. ? when opening them in the output mode, the input mode of the initial status remains until the mode of the ports is switched over to the output mode by the program after reset. thus, the potential at these pins is undefined and the power source current may increase in the input mode. with regard to an effects on the system, thoroughly perform system evaluation on the user side. ? since the direction register setup may be changed because of a program runaway or noise, set direction registers by program periodically to increase the reliability of program. ? the avss pin when not using the a-d converter : ? when not using the a-d converter, handle a power source pin for the a-d converter, avss pin as follows: ? avss:connect to the vss pin (2) termination remarks input ports and i/o ports : do not open in the input mode. l reason ? the power source current may increase depending on the first-stage circuit. ? an effect due to noise may be easily produced as compared with proper termination and a shown on the above. i/o ports : when setting for the input mode, do not connect to v cc or v ss directly. l reason if the direction register setup changes for the output mode because of a program runaway or noise, a short circuit may occur between a port and v cc (or v ss ). a i/o ports : when setting for the input mode, do not connect multiple ports in a lump to v cc or v ss through a resistor. l reason if the direction register setup changes for the output mode because of a program runaway or noise, a short circuit may occur between ports. ? at the termination of unused pins, perform wiring at the shortest possible distance (20 mm or less) from microcomputer pins.
2-6 3850/3851 group users manual application 2.2 timer 2.2 timer this paragraph explains the registers setting method and the notes relevant to the timers. 2.2.1 memory map fig. 2.2.1 memory map of registers relevant to timers 2.2.2 relevant registers fig. 2.2.2 structure of prescaler 12, prescaler x, prescaler y 0020 16 0021 16 0022 16 0023 16 0024 16 0025 16 0026 16 prescaler 12 (pre12) timer 1 (t1) timer 2 (t2) timer xy mode register (tm) prescaler x (prex) timer x (tx) 003c 16 003e 16 interrupt control register 1 (icon1) 0027 16 0028 16 timer count source set register (tcss) timer y (ty) prescaler y (prey) 003d 16 003f 16 interrupt request register 1 (ireq1) interrupt request register 2 (ireq2) interrupt control register 2 (icon2) prescaler 12, prescaler x, prescaler y b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 1 1 1 1 1 1 1 1 prescaler 12 (pre12) [address : 20 16 ] prescaler x (prex) [address : 24 16 ] prescaler y (prey) [address : 26 16 ] ?set a count value of each prescaler. ?the value set in this register is written to both each prescaler and the corresponding prescaler latch at the same time. ?when this register is read out, the count value of the corres- ponding prescaler is read out.
3850/3851 group users manual application 2-7 2.2 timer fig. 2.2.3 structure of timer 1 fig. 2.2.4 structure of timer 2, timer x, timer y timer 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 1 0 0 0 0 0 0 0 timer 1 (t1) [address : 21 16 ] ?set a count value of timer 1. ?the value set in this register is written to both timer 1 and timer 1 latch at the same time. ?when this register is read out, the timer 1s count value is read out. timer 2, timer x, timer y b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 1 1 1 1 1 1 1 1 timer 2 (t2) [address : 22 16 ] timer x (tx) [address : 25 16 ] timer y (ty) [address : 27 16 ] ?set a count value of each timer. ?the value set in this register is written to both each timer and each timer latch at the same time. ?when this register is read out, each timers count value is read out.
2-8 3850/3851 group users manual application 2.2 timer fig. 2.2.5 structure of timer xy mode register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 2 3 4 5 6 7 name 0 0 0 0 timer xy mode register (tm) [address : 23 ] timer xy mode register 0 0 0 0 0 : timer mode 0 1 : pulse output mode 1 0 : event counter mode 1 1 : pulse width measurement mode b1 b0 1 0 timer x operating mode bits cntr 0 active edge switch bit the function depends on the operating mode of timer x. (refer to table 2.2.1) timer x count stop bit 0 : count start 1 : count stop 16 timer y operating mode bits 0 0 : timer mode 0 1 : pulse output mode 1 0 : event counter mode 1 1 : pulse width measurement mode b5 b4 the function depends on the operating mode of timer y. (refer to table 2.2.1) 0 : count start 1 : count stop cntr 1 active edge switch bit timer y count stop bit timer x /timer y operation modes timer mode pulse output mode event counter mode pulse width measurement mode cntr 0 / cntr 1 active edge switch bit (bits 2, 6 of address 23 16 ) contents 0 cntr 0 / cntr 1 interrupt request occurrence: falling edge ; no influence to timer count 1 cntr 0 / cntr 1 interrupt request occurrence: rising edge ; no influence to timer count 0 pulse output start: beginning at h level cntr 0 / cntr 1 interrupt request occurrence: falling edge 1 pulse output start: beginning at l level cntr 0 / cntr 1 interrupt request occurrence: rising edge 0 timer x / timer y: rising edge count cntr 0 / cntr 1 interrupt request occurrence: falling edge 1 timer x / timer y: falling edge count cntr 0 / cntr 1 interrupt request occurrence: rising edge 0 timer x / timer y: h level width measurement cntr 0 / cntr 1 interrupt request occurrence: falling edge 1 timer x / timer y: l level width measurement cntr 0 / cntr 1 interrupt request occurrence: rising edge table 2.2.1 cntr 0 /cntr 1 active edge switch bit function
3850/3851 group users manual application 2-9 2.2 timer fig. 2.2.6 structure of timer count source set register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name timer count source selection register (tcss) [address : 28 16 ] timer count source selection register timer x count source selection bit timer y count source selection bit 0 : f(x in )/16 (f(x cin )/16 at low-speed mode) 1 : f(x in )/2 (f(x cin )/2 at low-speed mode) 0 : f(x in )/16 (f(x cin )/16 at low-speed mode) 1 : f(x in )/2 (f(x cin )/2 at low-speed mode) timer 12 count source selection bit 0 : f(x in )/16 (f(x cin )/16 at low-speed mode) 1 : f(x cin ) 0 0 0 0 0 0 0 0 5 5 5 5 5 nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0.
2-10 3850/3851 group users manual application 2.2 timer interrupt request register 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt request register 1 (ireq1) [address : 3c 16 ] int 0 interrupt request bit scl/sda interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued i 2 c interrupt request bit timer x interrupt request bit ] : these bits can be cleared to 0 by program, but cannot be set to 1. 0 : no interrupt request issued 1 : interrupt request issued int 1 interrupt request bit int 2 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued int 3 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued ] ] ] ] ] ] ] timer y interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued ] fig. 2.2.7 structure of interrupt request register 1 interrupt request register 2 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt request register 2 (ireq2) [address : 3d 16 ] nothing is allocated for this bit. this is a write disabled bit. when this bit is read out, the value is 0. 5 timer 1 interrupt request bit timer 2 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued cntr 1 interrupt request bit ad converter interrupt request bit ] : these bits can be cleared to 0 by program, but cannot be set to 1. 0 : no interrupt request issued 1 : interrupt request issued serial i/o receive interrupt request bit serial i/o transmit interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued cntr 0 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued ] ] ] ] ] ] ] fig. 2.2.8 structure of interrupt request register 2
3850/3851 group users manual application 2-11 2.2 timer interrupt control register 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt control register 1 (icon1) [address : 3e 16 ] int 0 interrupt enable bit scl/sda interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled i 2 c interrupt enable bit timer x interrupt enable bit int 1 interrupt enable bit int 2 interrupt enable bit int 3 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled timer y interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled fig. 2.2.9 structure of interrupt control register 1 interrupt control register 2 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt control register 2 (icon2) [address : 3f 16 ] fix this bit to 0. timer 1 interrupt enable bit timer 2 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled cntr 1 interrupt enable bit ad converter interrupt enable bit serial i/o receive interrupt enable bit serial i/o transmit interrupt enable bit cntr 0 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 fig. 2.2.10 structure of interrupt control register 2
2-12 3850/3851 group users manual application 2.2 timer 2.2.3 timer application examples (1) basic functions and uses [function 1] control of event interval (timer x, timer y, timer 1, timer 2) when a certain time, by setting a count value to each timer, has passed, the timer interrupt request occurs. ?generation of an output signal timing ?generation of a wait time [function 2] control of cyclic operation (timer x, timer y, timer 1, timer 2) the value of the timer latch is automatically written to the corresponding timer each time the timer underflows, and each timer interrupt request occurs in cycles. ?generation of cyclic interrupts ?clock function (measurement of 250 ms); see application example 1 ?control of a main routine cycle [function 3] output of rectangular waveform (timer x, timer y) the output level of the cntr 0 pin or cntr 1 pin is inverted each time the timer underflows (in the pulse output mode). ?piezoelectric buzzer output; see application example 2 ?generation of the remote control carrier waveforms [function 4] count of external pulses (timer x, timer y) external pulses input to the cntr 0 pin or cntr 1 pin are counted as the timer count source (in the event counter mode). ?frequency measurement; see application example 3 ?division of external pulses ?generation of interrupts due to a cycle using external pulses as the count source; count of a reel pulse [function 5] measurement of external pulse width (timer x, timer y) the h or l level width of external pulses input to cntr 0 pin or cntr 1 pin is measured (in the pulse width measurement mode). ?measurement of external pulse frequency (measurement of pulse width of fg pulse ] for a motor); see application example 4 ?measurement of external pulse duty (when the frequency is fixed) fg pulse ] : pulse used for detecting the motor speed to control the motor speed.
3850/3851 group users manual application 2-13 2.2 timer (2) timer application example 1: clock function (measurement of 250 ms) outline : the input clock is divided by the timer so that the clock can count up at 250 ms intervals. specifications : ?the clock f(x in ) = 4.19 mhz (2 22 hz) is divided by the timer. ?the clock is counted up in the process routine of the timer x interrupt which occurs at 250 ms intervals. figure 2.2.11 shows the timers connection and setting of division ratios; figure 2.2.12 shows the relevant registers setting; figure 2.2.13 shows the control procedure. fig. 2.2.11 timers connection and setting of division ratios f(x in ) = 4.19 mhz 250 ms 1/16 1/256 1/256 1/4 1 second dividing by 4 with software timer x count source selection bit prescaler x timer x timer x interrupt request bit 0 or 1 0 : no interrupt request issued 1 : interrupt request issued
2-14 3850/3851 group users manual application 2.2 timer fig. 2.2.12 relevant registers setting icon1 timer x interrupt: enabled 1 ireq1 tm 0 0 1 prex 255 tx 255 b0 b7 b0 b7 b0 b7 b0 b7 b0 b7 tcss 0 timer x count source : f(x in )/16 b0 b7 timer count source selection register (address 28 16 ) timer xy mode register (address 23 16 ) timer x operating mode: timer mode timer x count: stop clear to 0 when starting count. prescaler x (address 24 16 ) timer x (address 25 16 ) set division ratio C 1 interrupt control register 1 (address 3e 16 ) interrupt request register 1 (address 3c 16 ) timer x interrupt request (becomes 1 at 250 ms intervals) 0
3850/3851 group users manual application 2-15 2.2 timer fig. 2.2.13 control procedure reset initialization sei tm ireq1 icon1 tcss prex tx tm cli 0 1 ..... ..... ..... 0 256 ?1 256 ?1 main processing tm prex tx ireq1 tm ..... 1 256 ?1 256 ?1 0 0 clock stop ? n y rti (address 23 16 ), bit3 (address 24 16 ) (address 25 16 ) (address 3c 16 ), bit6 (address 23 16 ), bit3 (address 23 16 ) (address 3c 16 ), bit6 (address 3e 16 ), bit6 clt ( note 2 ) cld ( note 3 ) push registers to stack (address 28 16 ), bit0 (address 24 16 ) (address 25 16 ) (address 23 16 ), bit3 0 ..... ( note 1 ) timer x interrupt process routine clock count up (1/4 second to year) pop registers xxxx1000 2 ?ll interrupts disabled ?imer x operating mode : timer mode ?lear timer x interrupt request bit ?imer x interrupt enabled ?imer x count source : f(x in /16) ?et ?ivision ratio ?1?to prescaler x and timer x ?imer x count start ?nterrupts enabled ?eset timer to restart count from 0 second after completion of clock set note 1 : perform procedure for completion of clock set only when completing clock set. note 2 : when using index x mode flag (t) note 3 : when using decimal mode flag (d) ?ush registers used in interrupt process routine ?udge whether clock stops ?lock count up ?op registers pushed to stack l x: this bit is not used here. set it to ??or ??arbitrarily.
2-16 3850/3851 group users manual application 2.2 timer (3) timer application example 2: piezoelectric buzzer output outline : the rectangular waveform output function of the timer is applied for a piezoelectric buzzer output. specifications : ?the rectangular waveform, dividing the clock f(x in ) = 4.19 mhz (2 22 hz) into about 2 khz (2048 hz), is output from the p2 7 /cntr 0 pin. ?the level of the p2 7 /cntr 0 pin is fixed to h while a piezoelectric buzzer output stops. figure 2.2.14 shows a peripheral circuit example, and figure 2.2.15 shows the timers connection and setting of division ratios. figures 2.2.16 shows the relevant registers setting, and figure 2.2.17 shows the control procedure. 3851 group p2 7 /cntr 0 pipipi..... 244 m s cntr 0 output the ??level is output while a piezoelectric buzzer output stops. 244 m s set a division ratio so that the underflow output period of the timer x can be 244 m s. fig. 2.2.14 peripheral circuit example 1/16 1/64 1/2 cntr 0 1 f(x in ) = 4.19 mhz timer x count source selection bit prescaler x timer x fixed fig. 2.2.15 timers connection and setting of division ratios
3850/3851 group users manual application 2-17 2.2 timer fig. 2.2.16 relevant registers setting tm tx 63 1 0 0 1 prex 0 b0 b7 b0 b7 b0 b7 tcss 0 b0 b7 icon1 0 b0 b7 timer x interrupt: disabled timer x count source : f(x in )/16 timer count source selection register (address 28 16 ) timer xy mode register (address 23 16 ) timer x operating mode: pulse output mode timer x count: stop clear to 0 when starting count. prescaler x (address 24 16 ) timer x (address 25 16 ) set division ratio C 1 interrupt control register 1 (address 3e 16 ) cntr 0 active edge switch: output starting at h level
2-18 3850/3851 group users manual application 2.2 timer fig. 2.2.17 control procedure reset p2 p2d tcss icon1 tm tx prex 1 ..... ..... ..... 0 0 xxxx 1 x 01 2 64 ?1 1 ?1 ..... output unit tm (address 23 16 ), bit3 0 (address 04 16 ), bit7 (address 05 16 ) (address 28 16 ), bit0 (address 3e 16 ), bit6 (address 23 16 ) (address 25 16 ) (address 24 16 ) tm (address 23 16 ), bit3 1 tx (address 25 16 ) 64 ?1 initialization l x: this bit is not used here. set it to ??or ??arbitrarily. 1 xxxxxxx2 main processing piezoelectric buzzer request ? yes start piezoelectric buzzer output stop piezoelectric buzzer output no ?imer x count source : f(x in )/16 ?imer x interrupt disabled ?top cntr 0 output; stop piezoelectric buzzer output ?et ?ivision ratio ?1?to timer x and prescaler x ?rocess piezoelectric buzzer request, generated during main processing, in output unit
3850/3851 group users manual application 2-19 2.2 timer (4) timer application example 3: frequency measurement outline : the following two values are compared to judge whether the frequency is within a valid range. ?a value by counting pulses input to p4 0 /cntr 1 pin with the timer. ?a reference value specifications : ?the pulse is input to the p4 0 /cntr 1 pin and counted by the timer y. ?a count value is read out at about 2 ms intervals, the timer 1 interrupt interval. when the count value is 28 to 40, it is judged that the input pulse is valid. ?because the timer is a down-counter, the count value is compared with 227 to 215 (note). note : 227 to 215 = {255 (initial value of counter) C 28} to {255 C 40}; 28 to 40 means the number of valid value. figure 2.2.18 shows the judgment method of valid/invalid of input pulses; figure 2.2.19 shows the relevant registers setting; figure 2.2.20 shows the control procedure. fig 2.2.18 judgment method of valid/invalid of input pulses input pulse 2 ms 71.4 m s = 28 counts ? ? ? ? ? ? ? ? ? ? ? ? 71.4 m s or more (14 khz m s or less) 71.4 m s (14 khz m s) 50 m s (20 khz m s) 50 m s or less (20 khz m s or more) invalid valid invalid 2 ms 50 m s = 40 counts
2-20 3850/3851 group users manual application 2.2 timer fig. 2.2.19 relevant registers setting tm pre12 63 t1 10 1 1 prey ty 7 0 255 icon1 0 ireq1 0 b0 b7 b0 b7 b0 b7 b0 b7 b0 b7 b0 b7 b0 b7 timer y interrupt: disabled timer xy mode register (address 23 16 ) timer y operating mode: event counter mode timer y count: stop clear to ??when starting count prescaler 12 (address 20 16 ) timer y (address 27 16 ) set ?ivision ratio ?1 interrupt control register 1 (address 3e 16 ) cntr 1 active edge switch: falling edge count prescaler y (address 26 16 ) timer 1 (address 21 16 ) interrupt request register 1 (address 3c 16 ) judgment of timer y interrupt request bit ( ??of this bit when reading the count value indicates the 256 or more pulses input in the condition of timer y = 255) set 255 just before counting pulses (after a certain time has passed, the number of input pulses is decreased from this value.) 1 b0 b7 timer 1 interrupt: enabled interrupt control register 2 (address 3f 16 ) icon2
3850/3851 group users manual application 2-21 2.2 timer (address 23 16 ) (address 20 16 ) (address 21 16 ) (address 26 16 ) (address 27 16 ) (address 3e 16 ), bit7 (address 3f 16 ), bit0 reset sei tm pre12 t1 prey ty icon1 icon2 tm cli ..... ..... 0 ireq1(address 3c 16 ), bit7 ? 0 1 rti ..... ty (address 27 16 ) (a) 214 < (a) < 228 0 fpulse 1 fpulse ty (address 27 16 ) ireq1 (address 3c 16 ), bit7 256 ?1 0 (address 23 16 ), bit7 l x: this bit is not used here. set it to ??or ??arbitrary. ?ll interrupts disabled ?imer y operating mode : event counter mode (count a falling edge of pulses input from cntr 1 pin.) ?et division ratio so that timer 1 interrupt will occur at 2 ms intervals. ?imer y count start ?nterrupts enabled note 1 : when using index x mode flag (t) note 2 : when using decimal mode flag (d) ?ush registers used in interrupt process routine ?op registers pushed to stack ?nitialize the counter value ?lear timer y interrupt request bit initialization 1110 xxxx2 64 ?1 8 ?1 1 ?1 256 ?1 0 ?imer 1 interrupt enabled timer 1 interrupt process routine clt ( note 1 ) cld ( note 2 ) push registers to stack ?rocess as out of range when the count value is 256 or more ?ead the count value ?tore the count value into accumulator (a) in range out of range ?ompare the read value with reference value ?tore the comparison result to flag fpulse process judgment result pop registers 1 ?imer y interrupt disabled fig. 2.2.20 control procedure
2-22 3850/3851 group users manual application 2.2 timer (5) timer application example 4: measurement of fg pulse width for motor outline : the timer x counts the h level width of the pulses input to the p2 7 /cntr 0 pin. an underflow is detected by the timer x interrupt and an end of the input pulse h level is detected by the cntr 0 interrupt. specifications : ?the timer x counts the h level width of the fg pulse input to the p2 7 /cntr 0 pin. when the clock frequency is 4.19 mhz, the count source is 3.8 m s, which is obtained by dividing the clock frequency by 16. measurement can be made up to 250 ms in the range of ffff 16 to 0000 16 . figure 2.2.21 shows the timers connection and setting of division ratio; figure 2.2.22 shows the relevant registers setting; figure 2.2.23 shows the control procedure. fig. 2.2.21 timers connection and setting of division ratios 250 ms 1/16 1/256 1/256 f(x in ) = 4.19 mhz timer x count source selection bit prescaler x timer x timer x interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 or 1
3850/3851 group users manual application 2-23 2.2 timer fig. 2.2.22 relevant registers setting tm prex 255 tx 01 1 1 255 icon1 ireq1 1 0 b0 b7 b0 b7 b0 b7 b0 b7 b0 b7 timer x interrupt: enabled timer xy mode register (address 23 16 ) timer x operating mode: pulse width measurement mode timer x count: stop clear to ??when starting count prescaler x (address 24 16 ) timer x (address 25 16 ) set ?ivision ratio ?1 interrupt control register 1 (address 3e 16 ) cntr 0 active edge switch: ? level width measurement cntr 0 interrupt: enabled interrupt request register 1 (address 3c 16 ) timer x interrupt request (set to ??automatically when timer x underflows) icon2 1 b0 b7 interrupt control register 2 (address 3f 16 ) ireq2 0 b0 b7 interrupt request register 2 (address 3d 16 ) cntr 0 interrupt request (set to ??automatically when ??level input came to the end)
2-24 3850/3851 group users manual application 2.2 timer fig. 2.2.23 control procedure (address 23 16 ) (address 24 16 ) (address 25 16 ) (address 3e 16 ), bit6 (address 3c 16 ), bit6 (address 3f 16 ), bit4 (address 3d 16 ), bit4 reset sei tm prex tx icon1 ireq1 icon2 ireq2 tm cli ..... ..... 0 ..... rti rti prex inverted (a) (a) low-order 8-bit result of pulse width measurement (a) high-order 8-bit result of pulse width measurement prex (address 24 16 ) tx (address 25 16 ) (address 23 16 ), bit3 256 ?1 256 ?1 1 0 1 0 xxxx 1011 2 tx inverted (a) 256 ?1 256 ?1 ?ll interrupts disabled ?imer x operating mode : pulse width measurement mode (measure ??level of pulses input from cntr 0 pin.) ?et division ratio so that timer x interrupt will occur at 250 ms intervals. ?imer x interrupt enabled ?lear timer x interrupt request bit ?ntr 0 interrupt enabled ?lear cntr 0 interrupt request bit ?imer x count start ?nterrupts enabled note 1 : when using index x mode flag (t) note 2 : when using decimal mode flag (d) ?ush registers used in interrupt process routine ?op registers pushed to stack pop registers initialization timer x interrupt process routine clt ( note 1 ) cld ( note 2 ) push registers to stack process errors ?rror occurs cntr 0 interrupt process routine ?et division ratio so that timer x interrupt will occur at 250 ms intervals. ?ead the count value and store it to ram l x: this bit is not used here. set it to ??or ??arbitrarily.
3850/3851 group users manual application 2-25 2.2 timer 2.2.4 notes on the timer l if a value n (between 0 and 255) is written to a timer latch, the frequency division ratio is 1/(n+1). l when switching the count source by the timer 12, x and y count source selection bit, the value of timer count is altered in unconsiderable amount owing to generating of a thin pulses in the count input signals. therefore, select the timer count source before set the value to the prescaler and the timer.
2-26 3850/3851 group users manual application 2.3 serial i/o 2.3 serial i/o this paragraph explains the registers setting method and the notes relevant to the serial i/o. 2.3.1 memory map fig. 2.3.1 memory map of registers relevant to serial i/o 0018 16 0019 16 001a 16 001b 16 001c 16 transmit/receive buffer register (tb/rb) serial i/o status register (siosts) serial i/o control register (siocon) uart control register (uartcon) baud rate generator (brg) 003f 16 003d 16 interrupt request register 2 (ireq2) interrupt control register 2 (icon2) ~ ~ ~ ~ ~ ~ ~ ~ 003a 16 interrupt edge selection register (intedge) ~ ~ ~ ~
3850/3851 group users manual application 2-27 2.3 serial i/o fig. 2.3.3 structure of serial i/o status register serial i/o status register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 1 serial i/o status register (siosts) [address : 19 16 ] nothing is allocated for this bit. this is a write disabled bit. when this bit is read out, the value is 1. 5 5 5 5 5 5 5 5 transmit buffer empty flag (tbe) 0 : (oe) (pe) (fe) = 0 1 : (oe) (pe) (fe) = 1 overrun error flag (oe) 0 : buffer full 1 : buffer empty receive buffer full flag (rbf) transmit shift register shift completion flag (tsc) parity error flag (pe) framing error flag (fe) summing error flag (se) 0 : buffer empty 1 : buffer full 0 : transmit shift in progress 1 : transmit shift completed 0 : no error 1 : overrun error 0 : no error 1 : parity error 0 : no error 1 : framing error fig. 2.3.2 structure of transmit/receive buffer register transmit/receive buffer register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name ? ? ? ? ? ? ? ? transmit/receive buffer register (tb/rb) [address : 18 16 ] the transmission data is written to or the receive data is read out from this buffer register. ? at writing: a data is written to the transmit buffer register. ? at reading: the contents of the receive buffer register are read out. note: the contents of transmit buffer register cannot be read out. the data cannot be written to the receive buffer register. 2.3.2 relevant registers
2-28 3850/3851 group users manual application 2.3 serial i/o fig. 2.3.5 structure of uart control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 1 uart control register (uartcon) [address : 1b 16 ] nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 1. 5 5 5 uart control register character length selection bit (chas) parity enable bit (pare) stop bit length selection bit (stps) parity selection bit (pars) in output mode 0 : cmos output 1 : n-channel open-drain output 0 : 8 bits 1 : 7 bits 0 : parity checking disabled 1 : parity checking enabled 0 : 1 stop bit 1 : 2 stop bits 0 : even parity 1 : odd parity p2 5 /txd p-channel output disable bit (poff) 1 1 0 fig. 2.3.4 structure of serial i/o control register serial i/o control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 serial i/o control register (siocon) [address : 1a 16 ] 0 : f(x in ) 1 : f(x in )/4 brg count source selection bit (css) 0 0 : transmit disabled 1 : transmit enabled 0 : receive disabled 1 : receive enabled transmit interrupt source selection bit (tic) transmit enable bit (te) receive enable bit (re) serial i/o enable bit (sioe) s rdy output enable bit (srdy) 0 : p2 7 pin operates as ordinary i/o pin 1 : p2 7 pin operates as s rdy output pin 0 : interrupt when transmit buffer has emptied 1 : interrupt when transmit shift operation is completed serial i/o synchronous clock selection bit (scs ) ? in clock synchronous serial i/o 0 : brg output devided by 4 1 : external clock input ? in uart 0 : brg output devided by 16 1 : external clock input devided by 16 serial i/o mode selection bit (siom) 0 : clock asynchronous(uart) serial i/o 1 : clock synchronous serial i/o 0 : serial i/o disabled (pins p2 4 to p2 7 operate as ordinary i/o pins) 1 : serial i/o enabled (pins p2 4 to p2 7 operate as serial i/o pins)
3850/3851 group users manual application 2-29 2.3 serial i/o fig. 2.3.6 structure of baud rate generator baud rate generator b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 ? ? ? ? ? ? ? ? baud rate generator (brg) [address : 1c 16 ] set a count value of baud rate generator. interrupt edge selection register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt edge selection register (intedge) [address : 3a 16 ] nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. int 0 interrupt edge selection bit int 1 interrupt edge selection bit 0 : falling edge active 1 : rising edge active 0 : falling edge active 1 : rising edge active int 2 interrupt edge selection bit int 3 interrupt edge selection bit 0 : falling edge active 1 : rising edge active 0 : falling edge active 1 : rising edge active 5 5 5 5 this is the reserved bit. do not write 1 to this bit. fig. 2.3.7 structure of interrupt edge selection register
2-30 3850/3851 group users manual application 2.3 serial i/o fig. 2.3.8 structure of interrupt request register 2 fig. 2.3.9 structure of interrupt control register 2 interrupt request register 2 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 interrupt request register 2 (ireq2) [address : 3d 16 ] nothing is allocated for this bit. this is a write disabled bit. when this bit is read out, the value is 0. 5 timer 1 interrupt request bit timer 2 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 cntr 1 interrupt request bit ad converter interrupt request bit ] : these bits can be cleared to 0 by program, but cannot be set to 1. serial i/o receive interrupt request bit serial i/o transmit interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued cntr 0 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued ] ] ] ] ] ] ] 0 : no interrupt request issued 1 : interrupt request issued interrupt control register 2 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt control register 2 (icon2) [address : 3f 16 ] fix this bit to 0. timer 1 interrupt enable bit timer 2 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled cntr 1 interrupt enable bit ad converter interrupt enable bit serial i/o receive interrupt enable bit serial i/o transmit interrupt enable bit cntr 0 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0
3850/3851 group users manual application 2-31 2.3 serial i/o 2.3.3 serial i/o connection examples (1) control of peripheral ic equipped with cs pin there are connection examples using a clock synchronous serial i/o mode. figure 2.3.10 shows connection examples of a peripheral ic equipped with the cs pin. fig. 2.3.10 serial i/o connection examples (1) port s clk t x d r x d port cs clk in out cs clk in out (4) connection of plural ic 3851 group peripheral ic 1 peripheral ic 2 port s clk t x d cs clk in out (2) transmission and reception 3851 group peripheral ic (e prom etc.) 2 (3) transmission and reception (when connecting r x d with t x d) (when connecting in with out in peripheral ic) cs clk in out 3851 group peripheral ic (e prom etc.) 2 ] 2 ?ort?means an output port controlled by software. note: port s clk t x d cs clk data (1) only transmission (using the r x d pin as an i/o port) 3851 group peripheral ic (osd controller etc.) ] 1 ] 1: select an n-channel open-drain output for t x d pin output control. ] 2: use the out pin of peripheral ic which is an n-channel open- drain output and becomes high impedance during receiving data. port s clk t x d r x d r x d
2-32 3850/3851 group users manual application 2.3 serial i/o (2) connection with microcomputer figure 2.3.11 shows connection examples with another microcomputer. fig. 2.3.11 serial i/o connection examples (2) (4) in uart s clk t x d r x d clk in out (2) selecting external clock 3851 group microcomputer (3) using s rdy signal output function (selecting an external clock) s rdy s clk t x d r x d rdy clk in out 3851 group microcomputer clk in out (1) selecting internal clock 3851 group microcomputer r x d t x d s clk t x d r x d r x d t x d 3851 group microcomputer
3850/3851 group users manual application 2-33 2.3 serial i/o 2.3.4 setting of serial i/o transfer data format a clock synchronous or clock asynchronous (uart) can be selected as a data format of the serial i/o. figure 2.3.12 shows the serial i/o transfer data format. fig. 2.3.12 serial i/o transfer data format 1st-8data-1sp st lsb serial i/o uart clock synchronous serial i/o 1st-7data-1sp st lsb 1st-8data-1par-1sp st lsb 1st-7data-1par-1sp st lsb 1st-8data-2sp st lsb 1st-7data-2sp st lsb 1st-8data-1par-2sp st lsb 1st-7data-1par-2sp st lsb msb sp msb sp msb par sp msb par sp msb 2sp msb 2sp msb par 2sp msb par 2sp lsb first st : start bit sp : stop bit par : parity bit
2-34 3850/3851 group users manual application 2.3 serial i/o 2.3.5 serial i/o application examples (1) communication using clock synchronous serial i/o (transmit/receive) outline : 2-byte data is transmitted and received, using the clock synchronous serial i/o. the s rdy signal is used for communication control. figure 2.3.13 shows a connection diagram, and figure 2.3.14 shows a timing chart. figure 2.3.15 shows a registers setting relevant to the transmitting side, and figure 2.3.16 shows registers setting relevant to the receiving side. fig. 2.3.13 connection diagram specifications : ? the serial i/o is used (clock synchronous serial i/o is selected.) ? synchronous clock frequency : 125 khz (f(x in ) = 4 mhz is divided by 32) ? the s rdy (receivable signal) is used. ? the receiving side outputs the s rdy signal at intervals of 2 ms (generated by timer), and 2-byte data is transferred from the transmitting side to the receiving side. fig. 2.3.14 timing chart (using clock synchronous serial i/o) ??? d 0 d 4 d 2 d 1 d 6 d 5 d 7 d 3 d 0 d 4 d 2 d 1 d 6 d 5 d 7 d 3 d 0 d 1 ??? ??? t x d s clk s rdy 2 ms p4 1 / int 0 s clk t x d 3851 group s rdy s clk r x d 3851 group transmitting side receiving side
3850/3851 group users manual application 2-35 2.3 serial i/o fig. 2.3.15 registers setting relevant to transmitting side serial i/o status register (address : 19 16 ) siosts transmit buffer empty flag ?confirm that the data has been transferred from transmit buffer register to transmit shift register. ?when this flag is ?? it is possible to write the next transmission data in to transmit buffer register. transmitting side transmit shift register shift completion flag confirm completion of transmitting 1-byte data with this flag. ??: transmit shift completed b7 b0 interrupt edge selection register (address : 3a 16 ) intedge int 0 interrupt edge selection bit : falling edge active b7 b0 baud rate generator (address : 1c 16 ) brg set ?ivision ratio ?1 7 b7 b0 serial i/o control register (address : 1a 16 ) siocon brg counter source selection bit : f(x in ) serial i/o synchronous clock selection bit : brg/4 transmit enable bit : transmit enabled receive enable bit : receive disabled serial i/o mode selection bit : clock synchronous serial i/o serial i/o enable bit : serial i/o enabled b7 b0 0 0 0 11 1 0
2-36 3850/3851 group users manual application 2.3 serial i/o b7 b0 receiving side serial i/o control register (address : 1a 16 ) siocon serial i/o synchronous clock selection bit : external clock s rdy output enable bit : s rdy output enabled transmit enable bit : transmit enabled set this bit to 1, using s rdy output. receive enable bit : receive enabled serial i/o mode selection bit : clock synchronous serial i/o serial i/o enable bit : serial i/o enabled 1 1 1 1 1 1 serial i/o status register (address : 19 16 ) siosts b7 b0 receive buffer full flag confirm completion of receiving 1-byte data with this flag. 1 : at completing reception 0 : at reading out contents of receive buffer register overrun error flag 1 : when data is ready in receive shift register while receive buffer register contains the data. parity error flag 1 : when a parity error occurs in enabled parity. framing error flag 1 : when stop bits cannot be detected at the specified timing summing error flag 1 : when any one of the following errors occurs. ? overrun error ? parity error ? framing error fig. 2.3.16 registers setting relevant to receiving side
3850/3851 group users manual application 2-37 2.3 serial i/o figure 2.3.17 shows a control procedure of the transmitting side, and figure 2.3.18 shows a control procedure of the receiving side. fig. 2.3.17 control procedure of transmitting side reset initialization (address : 1a 16 ) (address : 1c 16 ) (address : 3a 16 ), bit0 siocon brg intedge 8 ?1 0 ..... tb/rb (address : 18 16 ) the first byte of a transmission data ?transmission data write transmit buffer empty flag is set to ?? by this writing. ?detection of int 0 falling edge ireq1 (address:3c 16 ), bit0? 1 0 ?judgment of transferring from transmit buffer register to transmit shift register (transmit buffer empty flag) siosts (address : 19 16 ), bit0? 1 0 tb/rb (address : 18 16 ) ?transmission data write transmit buffer empty flag is set to ?? by this writing. the second byte of a transmission data ?judgment of transferring from transmit buffer register to transmit shift register (transmit buffer empty flag) siosts (address : 19 16 ), bit0? 1 0 ?judgment of shift completion of transmit shift register (transmit shift register shift completion flag) siosts (address : 19 16 ), bit2? 1 0 ireq1 (address : 3c 16 ), bit0 0 1101xx00 2 l x: this bit is not used here. set it to ??or ??arbitrarily.
2-38 3850/3851 group users manual application 2.3 serial i/o fig. 2.3.18 control procedure of receiving side pass 2 ms? reset initialization siocon (address : 1a 16 ) 1111x11x 2 ..... tb/rb (address : 18 16 ) dummy data ? s rdy output s rdy signal is output by writing data to the tb/rb. using the s rdy , set transmit enable bit (bit4) of the siocon to 1. ? an interval of 2 ms generated by timer. y n ? judgement of completion of receiving (receive buffer full flag) siosts (address : 19 16 ), bit1? 1 0 read out reception data from tb/rb (address : 18 16 ) ? reception of the first byte data. receive buffer full flag is set to 0 by reading data. ? judgement of completion of receiving (receive buffer full flag) siosts (address : 19 16 ), bit1? 1 0 read out reception data from tb/rb (address : 18 16 ) ? reception of the second byte data. receive buffer full flag is set to 0 by reading data. l x: this bit is not used here. set it to 0 or 1 arbitrarily.
3850/3851 group users manual application 2-39 2.3 serial i/o cs do 0 do 1 do 2 do 3 clk data (2) output of serial data (control of peripheral ic) outline : 4-byte data is transmitted and received, using the clock synchronous serial i/o. the cs signal is output to a peripheral ic through port p4 3 . figure 2.3.19 shows a connection diagram, and figure 2.3.20 shows a timing chart. fig. 2.3.19 connection diagram p4 3 s clk t x d cs peripheral ic 3851 group example for using serial i/o data cs clk clk data specifications : ? the serial i/o is used (clock synchronous serial i/o is selected.) ? synchronous clock frequency : 125 khz (f(x in ) = 4 mhz is divided by 32) ? transfer direction : lsb first ? the serial i/o interrupt is not used. ? port p4 3 is connected to the cs pin (l active) of the peripheral ic for transmission control; the output level of port p4 3 is controlled by software. fig. 2.3.20 timing chart
2-40 3850/3851 group users manual application 2.3 serial i/o figure 2.3.21 shows registers setting relevant to serial i/o, and figure 2.3.22 shows a setting of serial i/o transmission data. fig. 2.3.22 setting of serial i/o transmission data fig. 2.3.21 registers setting relevant to serial i/o serial i/o synchronous clock selection bit : brg/4 s rdy output enable bit : s rdy output disabled 0 serial i/o transmit interrupt enable bit : interrupt disabled icon2 interrupt control register 2 (address : 3f 16 ) serial i/o transmit interrupt request bit confirm completion of transmitting 1-byte data by one unit. ??: transmit shift completion ireq2 interrupt request register 2 (address : 3d 16 ) 00 1 siocon serial i/o control register (address : 1a 16 ) 0 0 11 brg count source selection bit : f(x in ) transmit interrupt source selection bit : transmit shift operating completion transmit enable bit : transmit enabled 1 receive enable bit : receive disabled b7 b0 0 b7 b0 b7 b0 serial i/o mode selection bit : clock synchronous serial i/o serial i/o enable bit : serial i/o enabled 0 p2 5 /t x d p-channel output disable bit : cmos output uartcon uart control register (address : 1b 16 ) b7 b0 7 set ?ivision ratio ?1 brg baud rate generator (address : 1c 16 ) b7 b0 set a transmission data. confirm that transmission of the previous data is completed (bit 3 of the interrupt request register 2 is ?? before writing data. tb/rb transmit/receive buffer register (address : 18 16 ) b7 b0
3850/3851 group users manual application 2-41 2.3 serial i/o when the registers are set as shown in fig. 2.3.21, the serial i/o can transmit 1-byte data by writing data to the transmit buffer register. thus, after setting the cs signal to l, write the transmission data to the transmit buffer register by each 1 byte, and return the cs signal to h when the target number of bytes has been transmitted. figure 2.3.23 shows a control procedure of serial i/o. p4 (address : 08 16 ), bit3 0 0 n y 1 ireq2 (address : 3d 16 ), bit3? complete to transmit data? initialization siocon uartcon brg icon2 p4 p4d .... .... (address : 1a 16 ) (address : 1b 16 ), bit4 (address : 1c 16 ) (address : 3f 16 ), bit3 (address : 08 16 ), bit3 (address : 09 16 ) 11011000 2 xxxx1xxx 2 ireq2 (address : 3d 16 ), bit3 0 tb/rb (address : 18 16 ) p4 (address : 08 16 ), bit3 1 a transmission data set the serial i/o. set the cs signal output level to ?? set the serial i/o transmit interrupt request bit to ?? write a transmission data. (start of transmit 1-byte data) judgment of completion of transmitting 1- byte data use any of ram area as a counter for counting the number of transmitted bytes. judgment of completion of transmitting the target number of bytes. return the cs signal output level to ?? when transmission of the target number of bytes is completed. l l l l l l l l l l serial i/o transmit interrupt : disabled set the cs signal output port. (??level output) reset l 0 8? 0 1 l x: this bit is not used here. set it to ??or ??arbitrarily. fig. 2.3.23 control procedure of serial i/o
2-42 3850/3851 group users manual application 2.3 serial i/o (3) cyclic transmission or reception of block data (data of specified number of bytes) between two microcomputers outline : when the clock synchronous serial i/o is used for communication, synchronization of the clock and the data between the transmitting and receiving sides may be lost because of noise included in the synchronous clock. it is necessary to correct that constantly, using heading adjustment. this heading adjustment is carried out by using the interval between blocks in this example. figure 2.3.24 shows a connection diagram. fig. 2.3.24 connection diagram specifications : ? the serial i/o is used (clock synchronous serial i/o is selected). ? synchronous clock frequency : 131 khz (f(x in ) = 4.19 mhz is divided by 32) ? byte cycle: 488 m s ? number of bytes for transmission or reception : 8 byte/block ? block transfer cycle : 16 ms ? block transfer term : 3.5 ms ? interval between blocks : 12.5 ms ? heading adjustment time : 8 ms limitations of the specifications : ? reading of the reception data and setting of the next transmission data must be completed within the time obtained from byte cycle C time for transferring 1-byte data (in this example, the time taken from generating of the serial i/o receive interrupt request to input of the next synchronous clock is 431 m s). ? heading adjustment time < interval between blocks must be satisfied. s clk master unit s clk slave unit t x d r x d t x d r x d
3850/3851 group users manual application 2-43 2.3 serial i/o the communication is performed according to the timing shown in figure 2.3.25. in the slave unit, when a synchronous clock is not input within a certain time (heading adjusment time), the next clock input is processed as the beginning (heading) of a block. when a clock is input again after one block (8 byte) is received, the clock is ignored. figure 2.3.26 shows relevant registers setting. fig. 2.3.25 timing chart d 0 byte cycle block transfer term block transfer cycle d 1 d 2 d 7 d 0 interval between blocks processing for heading adjustment heading adjustment time fig. 2.3.26 relevant registers setting master unit transmit enabled siocon serial i/o control register (address : 1a 16 ) synchronous clock : brg/4 transmit interrupt source : transmit shift operating completion receive enabled clock synchronous serial i/o 0 1 1 110 0 1 serial i/o enabled brg count source : f(x in ) s rdy output disabled not be effected by external clock transmit enabled siocon serial i/o control register (address : 1a 16 ) not use the serial i/o transmit interrupt receive enabled clock synchronous serial i/o 1 1 1 1 slave unit 1 serial i/o enabled 0 synchronous clock : external clock uartcon uart control register (address : 1b 16 ) p2 5 /t x d pin : cmos output 0 both of units b7 b0 7 brg b7 b0 baud rate generator (address : 1c 16 ) set division ratio C 1 b7 b0 b7 b0 s rdy output disabled
2-44 3850/3851 group users manual application 2.3 serial i/o control procedure : l control in the master unit after setting the relevant registers shown in figure 2.3.26, the master unit starts transmission or reception of 1-byte data by writing transmission data to the transmit buffer register. to perform the communication in the timing shown in figure 2.3.25, take the timing into account and write transmission data. additionally, read out the reception data when the serial i/o transmit interrupt request bit is set to 1, or before the next transmission data is written to the transmit buffer register. figure 2.3.27 shows a control procedure of the master unit using timer interrupts. interrupt processing routine executed every 488 m s write a transmission data read a reception data n within a block transfer period? y y complete to transfer a block? n rti write the first transmission data (first byte) in a block count a block interval counter n start a block transfer? y generate a certain block interval by using a timer or other functions. check the block interval counter and determine to start a block transfer. l l clt ( note 1 ) cld ( note 2 ) push register to stack note 1: when using the index x mode flag (t). note 2: when using the decimal mode flag (d). push the register used in the interrupt processing routine into the stack. l pop registers pop registers which is pushed to stack. l fig. 2.3.27 control procedure of master unit
3850/3851 group users manual application 2-45 2.3 serial i/o l control in the slave unit after setting the relevant registers as shown in figure 2.3.26, the slave unit becomes the state where a synchronous clock can be received at any time, and the serial i/o receive interrupt request bit is set to 1 each time an 8-bit synchronous clock is received. in the serial i/o receive interrupt processing routine, the data to be transmitted next is written to the transmit buffer register after the received data is read out. however, if no serial i/o receive interrupt occurs for a certain time (heading adjustment time or more), the following processing will be performed. 1. the first 1-byte data of the transmission data in the block is written into the transmit buffer register. 2. the data to be received next is processed as the first 1 byte of the received data in the block. figure 2.3.28 shows a control procedure of the slave unit using the serial i/o receive interrupt and any timer interrupt (for heading adjustment). fig. 2.3.28 control procedure of slave unit write a transmission data read a reception data n within a block transfer term? y y a received byte counter 3 8? n rti write dummy data (ff 16 ) a received byte counter +1 heading adjustment counter initial value ( note 3 ) serial i/o receive interrupt processing routine timer interrupt processing routine heading adjustment counter C 1 n heading adjustment counter = 0? y rti write the first transmission data (first byte) in a block a received byte counter 0 confirm the received byte counter to judge the block transfer term. in this example, set the value which is equal to the heading adjustment time divided by the timer interrupt cycle as the initial value of the heading adjustment counter. for example: when the heading adjustment time is 8 ms and the timer interrupt cycle is 1 ms, set 8 as the initial value. 3: l clt ( note 1 ) cld ( note 2 ) push register to stack push the register used in the interrupt processing routine into the stack. l clt ( note 1 ) cld ( note 2 ) push register to stack push the register used in the interrupt processing routine into the stack. l pop registers pop registers which is pushed to stack. l pop registers pop registers which is pushed to stack. l notes 1: when using the index x mode flag (t). 2: when using the decimal mode flag (d).
2-46 3850/3851 group users manual application 2.3 serial i/o (4) communication (transmit/receive) using asynchronous serial i/o (uart) outline : 2-byte data is transmitted and received, using the asynchronous serial i/o. port p4 0 is used for communication control. figure 2.3.29 shows a connection diagram, and figure 2.3.30 shows a timing chart. fig. 2.3.29 connection diagram (communication using uart) transmitting side p4 0 3851 group p4 0 3851 group receiving side t x dr x d specifications : ? the serial i/o is used (uart is selected). ? transfer bit rate : 9600 bps (f(x in ) = 4.9152 mhz is divided by 512) ? communication control using port p4 0 (the output level of port p4 0 is controlled by softoware.) ? 2-byte data is transferred from the transmitting side to the receiving side at intervals of 10 ms generated by the timer. fig. 2.3.30 timing chart (using uart) p4 0 t x d 10 ms d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st sp(2) d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st sp(2) d 0 st ???? ????
3850/3851 group users manual application 2-47 2.3 serial i/o brg count source brg setting value transfer bit rate (bps) (note 2) (note 1) at f(x in ) = 4.9152 mh z at f(x in ) = 8 mh z f(x in )/4 255(ff 16 ) 300 488.28125 f(x in )/4 127(7f 16 ) 600 976.5625 f(x in )/4 63(3f 16 ) 1200 1953.125 f(x in )/4 31(1f 16 ) 2400 3906.25 f(x in )/4 15(0f 16 ) 4800 7812.5 f(x in )/4 7(07 16 ) 9600 15625 f(x in )/4 3(03 16 ) 19200 31250 f(x in )/4 1(01 16 ) 38400 62500 f(x in ) 3(03 16 ) 76800 125000 f(x in ) 1(01 16 ) 153600 250000 f(x in ) 0(00 16 ) 307200 500000 notes 1: select the brg count source with bit 0 of the serial i/o control register (address : 1a 16 ). 2: equation of transfer bit rate: ] m: when bit 0 of the serial i/o control register (address : 1a 16 ) is set to 0, a value of m is 1. when bit 0 of the serial i/o control register (address : 1a 16 ) is set to 1, a value of m is 4. table 2.3.1 shows setting examples of the baud rate generator (brg) values and transfer bit rate values; figure 2.3.31 shows registers setting relevant to the transmitting side; figure 2.3.32 shows registers setting relevant to the receiving side. table 2.3.1 setting examples of baud rate generator values and transfer bit rate values transfer bit rate (bps) = (brg setting value + 1) 5 16 5 m ] f(x in )
2-48 3850/3851 group users manual application 2.3 serial i/o fig. 2.3.31 registers setting relevant to transmitting side serial i/o status register (address : 19 16 ) siosts transmitting side baud rate generator (address : 1c 16 ) brg 7 siocon 1001 01 0 uart control register (address : 1b 16 ) uartcon 0 01 0 f(x in ) transfer bit rate 16 5 5 m C1 b7 b0 serial i/o control register (address : 1a 16 ) b7 b0 b7 b0 b7 b0 set when bit 0 of the serial i/o control register (address : 1a 16 ) is set to 0, a value of m is 1. when bit 0 of the serial i/o control register (address : 1a 16 ) is set to 1, a value of m is 4. ] ] brg count source selection bit : f(x in )/4 serial i/o synchronous clock selection bit : brg/16 transmit enable bit : transmit enabled receive enable bit : receive disabled serial i/o mode selection bit : asynchronous serial i/o(uart) serial i/o enable bit : serial i/o enabled s rdy output enable bit : s rdy out disabled character length selection bit : 8 bits parity enable bit : parity checking disabled p2 5 /t x d p-channel output disable bit : cmos output stop bit length selection bit : 2 stop bits transmit buffer empty flag ? confirm that the data has been transferred from transmit buffer register to transmit shift register. ? when this flag is 1, it is possible to write the next transmission data in to transmit buffer register. transmit shift register shift completion flag confirm completion of transmitting 1-byte data with this flag. 1 : transmit shift completed
3850/3851 group users manual application 2-49 2.3 serial i/o receiving side serial i/o status register (address : 19 16 ) siosts brg 7 serial i/o control register (address : 1a 16 ) siocon 10 0 101 0 uartcon 0 10 b7 b0 b7 b0 uart control register (address : 1b 16 ) b7 b0 character length selection bit : 8 bits parity enable bit : parity checking disabled stop bit length selection bit : 2 stop bits baud rate generator (address : 1c 16 ) b7 b0 f(x in ) transfer bit rate 16 5 5 m C1 set when bit 0 of the serial i/o control register (address : 1a 16 ) is set to 0, a value of m is 1. when bit 0 of the serial i/o control register (address : 1a 16 ) is set to 1, a value of m is 4. ] ] brg count source selection bit : f(x in )/4 serial i/o synchronous clock selection bit : brg/16 transmit enable bit : transmit disabled receive enable bit : receive enabled serial i/o mode selection bit : asynchronous serial i/o(uart) serial i/o enable bit : serial i/o enabled s rdy output enable bit : s rdy out disabled receive buffer full flag confirm completion of receiving 1-byte data with this flag. 1 : at completing reception 0 : at reading out contents of receive buffer register overrun error flag 1 : when data is ready in receive shift register while receive buffer register contains the data. parity error flag 1 : when a parity error occurs in enabled parity. framing error flag 1 : when stop bits cannot be detected at the specified timing summing error flag 1 : when any one of the following errors occurs. ? overrun error ? parity error ? framing error fig. 2.3.32 registers setting relevant to receiving side
2-50 3850/3851 group users manual application 2.3 serial i/o figure 2.3.33 shows a control procedure of the transmitting side, and figure 2.3.34 shows a control procedure of the receiving side. fig. 2.3.33 control procedure of transmitting side siosts (address : 19 16 ), bit0? reset ?communication completion (address : 1a 16 ) (address : 1b 16 ) (address : 1c 16 ) (address : 08 16 ), bit0 (address : 09 16 ) p4 (address : 08 16 ), bit0 1 pass 10 ms? y n tb/rb (address : 18 16 ) the second byte of a transmission data 1 0 siosts (address : 19 16 ), bit2? 1 0 initialization siocon uartcon brg p4 p4d 1001x001 2 xxx01x00 2 8? ..... tb/rb (address : 18 16 ) the first byte of a transmission data p4 (address : 08 16 ), bit0 0 1 0 ?port p4 0 set for communication control ?an interval of 10 ms generated by timer ?communication start ?transmission data write transmit buffer empty flag is set to ?? by this writing. ?transmission data write transmit buffer empty flag is set to ?? by this writing. ?judgment of transferring data from transmit buffer register to transmit shift register (transmit buffer empty flag) ?judgment of transferring data from transmit buffer register to transmit shift register (transmit buffer empty flag) ?judgment of shift completion of transmit shift register (transmit shift register shift completion flag) siosts (address : 19 16 ), bit0? 0 xxxxxxx1 2 l l x: this bit is not used here. set it to ??or ??arbitrarily.
3850/3851 group users manual application 2-51 2.3 serial i/o fig. 2.3.34 control procedure of receiving side (address : 1a 16 ) (address : 1b 16 ) (address : 1c 16 ) (address : 09 16 ) reset ?judgment of completion of receiving (receive buffer full flag) siosts (address : 19 16 ), bit1? 1 0 read out a reception data from rb (address : 18 16 ) siosts (address : 19 16 ), bit6? 0 1 initialization siocon uartcon brg p4d 1010x001 2 xxxx1x00 2 8? xxxxxxx0 2 ..... siosts (address : 19 16 ), bit1? 1 0 ?judgment of an error flag siosts (address : 19 16 ), bit6? 0 1 p4 (address : 08 16 ), bit0? 0 1 siocon (address : 1a 16 ) siocon (address : 1a 16 ) 0000x000 2 1010x001 2 processing for error read out a reception data from rb (address : 18 16 ) ?reception of the first byte data receive buffer full flag is set to ??by reading data. ?judgment of completion of receiving (receive buffer full flag) ?reception of the second byte data receive buffer full flag is set to ??by reading data. ?judgment of an error flag ?countermeasure for a bit slippage l l x: this bit is not used here. set it to ??or ??arbitrarily.
2-52 3850/3851 group users manual application 2.3 serial i/o 2.3.6 notes on serial i/o (1) notes when selecting clock synchronous serial i/o stop of transmission operation clear the serial i/o enable bit and the transmit enable bit to 0 (serial i/o and transmit disabled). l reason since transmission is not stopped and the transmission circuit is not initialized even if only the serial i/o enable bit is cleared to 0 (serial i/o disabled), the internal transmission is running (in this case, since pins txd, rxd, s clk , and s rdy function as i/o ports, the transmission data is not output). when data is written to the transmit buffer register in this state, data starts to be shifted to the transmit shift register. when the serial i/o enable bit is set to 1 at this time, the data during internally shifting is output to the txd pin and an operation failure occurs. stop of receive operation clear the receive enable bit to 0 (receive disabled), or clear the serial i/o enable bit to 0 (serial i/o disabled). a stop of transmit/receive operation clear both the transmit enable bit and receive enable bit to 0 (transmit and receive disabled). (when data is transmitted and received in the clock synchronous serial i/o mode, any one of data transmission and reception cannot be stopped.) l reason in the clock synchronous serial i/o mode, the same clock is used for transmission and reception. if any one of transmission and reception is disabled, a bit error occurs because transmission and reception cannot be synchronized. in this mode, the clock circuit of the transmission circuit also operates for data reception. accordingly, the transmission circuit does not stop by clearing only the transmit enable bit to 0 (transmit disabled). also, the transmission circuit is not initialized by clearing the serial i/o enable bit to 0 (serial i/o disabled) (refer to (1) ).
3850/3851 group users manual application 2-53 2.3 serial i/o (2) notes when selecting clock asynchronous serial i/o stop of transmission operation clear the transmit enable bit to 0 (transmit disabled). l reason since transmission is not stopped and the transmission circuit is not initialized even if only the serial i/o enable bit is cleared to 0 (serial i/o disabled), the internal transmission is running (in this case, since pins txd, rxd, s clk , and s rdy function as i/o ports, the transmission data is not output). when data is written to the transmit buffer register in this state, data starts to be shifted to the transmit shift register. when the serial i/o enable bit is set to 1 at this time, the data during internally shifting is output to the txd pin and an operation failure occurs. stop of receive operation clear the receive enable bit to 0 (receive disabled). a stop of transmit/receive operation only transmission operation is stopped. clear the transmit enable bit to 0 (transmit disabled). l reason since transmission is not stopped and the transmission circuit is not initialized even if only the serial i/o enable bit is cleared to 0 (serial i/o disabled), the internal transmission is running (in this case, since pins txd, rxd, s clk , and s rdy function as i/o ports, the transmission data is not output). when data is written to the transmit buffer register in this state, data starts to be shifted to the transmit shift register. when the serial i/o enable bit is set to 1 at this time, the data during internally shifting is output to the txd pin and an operation failure occurs. only receive operation is stopped. clear the receive enable bit to 0 (receive disabled). (3) s rdy output of reception side when signals are output from the s rdy pin on the reception side by using an external clock in the clock synchronous serial i/o mode, set all of the receive enable bit, the s rdy output enable bit, and the transmit enable bit to 1 (transmit enabled). (4) setting serial i/o control register again set the serial i/o control register again after the transmission and the reception circuits are reset by clearing both the transmit enable bit and the receive enable bit to 0. fig. 2.3.35 sequence of setting serial i/o control register again clear both the transmit enable bit (te) and the receive enable bit (re) to 0 set the bits 0 to 3 and bit 6 of the serial i/o control register set both the transmit enable bit (te) and the receive enable bit (re), or one of them to 1 can be set with the ldm instruction at the same time
2-54 3850/3851 group users manual application 2.3 serial i/o (5) data transmission control with referring to transmit shift register completion flag the transmit shift register completion flag changes from 1 to 0 with a delay of 0.5 to 1.5 shift clocks. when data transmission is controlled with referring to the flag after writing the data to the transmit buffer register, note the delay. (6) transmission control when external clock is selected when an external clock is used as the synchronous clock for data transmission, set the transmit enable bit to 1 at h of the s clk input level. also, write the transmit data to the transmit buffer register (serial i/o shift register) at h of the s clk input level. (7) transmit interrupt request when transmit enable bit is set the transmission interrupt request bit is set and the interruption request is generated even when selecting timing that either of the following flags is set to 1 as timing where the transmission interruption is generated. ? transmit buffer empty flag is set to 1 ? transmit shift register completion flag is set to 1 therefore, when the transmit interrupt is used, set the transmit interrupt enable bit to transmit enabled as the following sequence. transmit enable bit is set to 1 transmit interrupt request bit is set to 0 l reason when the transmission enable bit is set to 1, the transmit buffer empty flag and transmit shift register completion flag are set to 1.
3850/3851 group users manual application 2-55 2.4 multi-master i 2 c-bus interface 2.4 multi-master i 2 c-bus interface the multi-master i 2 c-bus interface is a serial communication circuit, conforming to the philips i 2 c-bus data transfer format. 2.4.1 memory map fig. 2.4.1 memory map of registers relevant to i 2 c-bus interface 2.4.2 relevant registers fig. 2.4.2 structure of i 2 c data shift register 002b 16 002c 16 002d 16 002e 16 002f 16 0030 16 003c 16 003e 16 i 2 c data shift register (s0) i 2 c address register (s0d) i 2 c status register (s1) i 2 c control register (s1d) i 2 c clock control register (s2) i 2 c start/stop condition control register (s2d) interrupt request register 1 (ireq1) interrupt control register 1 (icon1) b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 ? ? ? ? ? ? ? ? i 2 c data shift register i 2 c data shift register (s0) [address : 2b 16 ] this register is an 8-bit shift register to store receive data or write transmit data. note: secure 8 machine cycles from clearing mst bit to ??(slave mode) until writing data to i 2 c data shift register. if executing the read-modify-write instruction(seb, clb etc.) for this register during transfer, data may become a value not intended.
2-56 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface fig. 2.4.3 structure of i 2 c address register fig. 2.4.4 structure of i 2 c status register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 i 2 c address register (s0d) [address : 2c ] read / write bit (rwb) 0 : write bit 1 : read bit 0 0 0 note: if the read-modify-write instruction(seb, clb, etc.) is executed for this register at detectiong the stop condition, data may become a value not to intend. i 2 c address register 16 slave address (sad0, sad1, sad2, sad3, sad4, sad5, sad6) these bits are compared with the address data transmitted from the master. b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 1 0 0 i 2 c status register (s1) [address : 2d 16 ] i 2 c status register 0 ? 0 : bus free 1 : bus busy last receive bit (lrb) bus busy flag (bb) arbitration lost detecting flag (al) 0 : not detected 1 : detected ( note1 ) communication mode specification bits (trx, mst) 00 : slave receive mode 01 : slave transmit mode 10 : master receive mode 11 : master transmit mode 0 0 0 : last bit = 0 1 : last bit = 1 ( note1 ) general call detecting flag (ad0) 0 : no general call detected 1 : general call detected( note1, 2 ) slave address comparison flag (aas) 0 : address disagreement 1 : address agreement ( note1, 2 ) 5 5 5 5 scl pin low hold bit (pin) 0 : scl pin low hold 1 : scl pin low release ( note3 ) notes 1: these bits and flags can be read out, but cannot be written. 2: these bits can be detected when data format select bit (als) of i c control register is 0 . 3: 1 can be written to this bit, but 0 cannot be written by program. 4: do not execute the read-modify-write instruction (seb, clb) for this refgister, because all bits of this register are changed by hardware. 2
3850/3851 group users manual application 2-57 2.4 multi-master i 2 c-bus interface fig. 2.4.5 structure of i 2 c control register i 2 c control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 i 2 c control register (s1d) [address : 2e 16 ] bit counter (number of transmit/receive bits) (bc0, bc1, bc2) 0 0 0 : 8 0 0 1 : 7 0 1 0 : 6 0 1 1 : 5 1 0 0 : 4 1 0 1 : 3 1 1 0 : 2 1 1 1 : 1 b2 b1 b0 i 2 c-bus interface enable bit (es0) 0 : disabled 1 : enabled data format selection bit (als) 0 : addressing format 1 : free data format addressing format selection bit (10 bit sad) 0 : 7-bit addressing format 1 : 10-bit addressing format sda/scl pin selection bit (tsel) i 2 c-bus interface pin input level selection bit (tiss) 0 : connect to ports p2 2 , p2 3 1 : connect to ports p2 4 , p2 5 ( note 1 ) 0 : cmos input 1 : smbus input notes 1: when using p2 4 and p2 5 as i 2 c-bus interface, they are automatically switched from cmos output to p-channel output disabled. 2: when the read-modify-write instruction is executed for this register at detectiong the start condition or at completing the byte transfer, data may become a value not intended.
2-58 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface table 2.4.1 set value of i 2 c clock control register and scl frequency scl frequency ( note ) (at f = 4 mhz, unit : khz) setting value of ccr4Cccr0 standard clock mode setting disabled setting disabled setting disabled high-speed clock mode ccr4 0 0 0 0 0 0 0 1 1 1 ccr3 0 0 0 0 0 0 0 1 1 1 ccr2 0 0 0 0 1 1 1 1 1 1 ccr1 0 0 1 1 0 0 1 0 1 1 ccr0 0 1 0 1 0 1 0 1 0 1 setting disabled setting disabled setting disabled 34.5 33.3 32.3 100 83.3 333 250 400 (note 3) 166 C (note 2) C (note 2) 500/ccr value (note 3) 1000/ccr value (note 3) 17.2 16.6 16.1 notes 1: duty of s cl clock output is 50 %. the duty becomes 35 to 45 % only when the high-speed clock mode is selected and ccr value = 5 (400 khz, at f = 4 mhz). h duration of the clock fluctuates from C4 to +2 machine cycles in the standard clock mode, and fluctuates from C2 to +2 machine cycles in the high-speed clock mode. in the case of negative fluctuation, the frequency does not increase because l duration is extended instead of h duration reduction. these are value when s cl clock synchronization by the synchronous function is not performed. ccr value is the decimal notation value of the s cl frequency control bits ccr4 to ccr0. 2: each value of s cl frequency exceeds the limit at f = 4 mhz or more. when using these setting value, use f of 4 mhz or less. 3: the data formula of s cl frequency is described below: f /(8 5 ccr value) standard clock mode f /(4 5 ccr value) high-speed clock mode (ccr value 1 5) f /(2 5 ccr value) high-speed clock mode (ccr value = 5) do not set 0 to 2 as ccr value regardless of f frequency. set 100 khz (max.) in the standard clock mode and 400 khz (max.) in the high-speed clock mode to the s cl frequency by setting the s cl frequency control bits ccr4 to ccr0. b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 2 3 4 5 6 7 name i 2 c clock control register (s2) [address : 2f 16 ] i 2 c clock control register 0 0 0 1 scl frequency control bits (ccr0, ccr1, ccr2, ccr3, ccr4) 0 : standard clock mode 1 : high-speed clock mode scl mode specification bit (fast mode) ack bit (ack bit) ack clock bit (ack) 0 : ack is returned 1 : ack is not returned 0 : no ack clock 1 : ack clock refer to table 2.4.1 0 fig. 2.4.6 structure of i 2 c clock control register
3850/3851 group user? manual application 2-59 2.4 multi-master i 2 c-bus interface fig. 2.4.7 structure of i 2 c start/stop condition control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 2 3 4 5 6 7 name 0 i 2 c start/stop condition control register (s2d) [address : 30 16 ] i 2 c start/stop condition control register 0 ? 1 start/stop condition set bit (ssc0, ssc1, ssc2, ssc3, ssc4) ( note ) 0 : falling edge active 1 : rising edge active s cl /s da interrupt pin polarity selection bit (sip) s cl /s da interrupt pin selection bit (sis) s cl release time = f ( m s) 5 5 5 (ssc+1) set up time = f ( m s) (ssc+1)/2 hold time = f ( m s) (ssc+1)/2 0 : s da valid 1 : s cl valid fix this bit to ?? 0 note : fix ssc0 bit to ?? 0 interrupt request register 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt request register 1 (ireq1) [address : 3c 16 ] int 0 interrupt request bit scl/sda interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued i 2 c interrupt request bit timer x interrupt request bit ] : these bits can be cleared to ??by program, but cannot be set to ?? 0 : no interrupt request issued 1 : interrupt request issued int 1 interrupt request bit int 2 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued int 3 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued ] ] ] ] ] ] ] timer y interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued ] fig. 2.4.8 structure of interrupt request register 1
2-60 3850/3851 group user? manual application 2.4 multi-master i 2 c-bus interface fig. 2.4.9 structure of interrupt control register 1 interrupt control register 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt control register 1 (icon1) [address : 3e 16 ] int 0 interrupt enable bit scl/sda interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled i 2 c interrupt enable bit timer x interrupt enable bit int 1 interrupt enable bit int 2 interrupt enable bit int 3 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled timer y interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled
3850/3851 group users manual application 2-61 2.4 multi-master i 2 c-bus interface 2.4.3 i 2 c-bus overview the i 2 c-bus is a both directions serial bus connected with two signal lines; the scl which transmits a clock and the sda which transmits a data. each port of the 3851 group has an n-channel open-drain structure for output and a cmos structure for input. the devices connected with the i 2 c-bus interface use an open drain, so that external pull-up resistors are required. accordingly, while any one of devices always outputs l, other devices cannot output h. figure 2.4.10 shows the i 2 c-bus connection structure. fig. 2.4.10 i 2 c-bus connection structure scl output scl input sda output sda input scl output scl input sda output sda input scl output scl input sda output sda input
2-62 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface 2.4.4 communication format figure 2.4.11 shows an i 2 c-bus communication format example. the i 2 c-bus consists of the following: ?start condition to indicate communication start ?slave address and data to specify each device ?ack to indicate acknowledgment of address and data ?stop condition to indicate communication completion. fig. 2.4.11 i 2 c-bus communication format example (1) start condition when communication starts, the master device outputs the start condition to the slave device. the i 2 c-bus defines that a data can be changed when a clock line is l. accordingly, data change when a clock line is h is treated as stop or start condition. the data line change from h to l when a clock line is h is start condition. (2) stop condition just as in start condition, the data line change from l to h when a clock line is h is stop condition. the term from start condition to stop condition is called bus busy. the master device is inhibited from starting data transfer during that term. the bus busy status can be judged by using the bb flag of i 2 c status register (bit 5 of address 002d 16 ). (3) slave address the slave address is transmitted after start condition. this address consists of 7 bits and the 7- th bit functions as the read/write (r/w) bit which indicates a data transmission method. the slave devices connected with the same i 2 c-bus must have their addresses, individually. it is because that address is defined for the master to specify the transmitted/received slave device. the read/write (r/w) bit indicates a data transmission direction; l means write from the master to the slave, and h means read in. (4) data the data has an 8-bit length. there are two cases depending on the read/write (r/w) bit of a slave address; one is from the master to the slave and the other is from the slave to the master. s r/w a a a scl sda p start ack w ack ack stop bus busy term slave address 7 bits data 8 bits data 8 bits addresses 0 to 6 data 0 to 7 data 0 to 7
3850/3851 group users manual application 2-63 2.4 multi-master i 2 c-bus interface (5) ack bit the ack bit clock is generated by the master. this is used for indication of acknowledgment on the sda line, the slaves busy and the data end. for example, the slave device makes the sda line l for acknowledgment when confirming the slave address following the start condition. the built-in i 2 c-bus interface has the slave address automatic judgment function and the ack acknowledgment function. l is automatically output when the ack bit of i 2 c clock control register (bit 6 of address 002f 16 ) is 0 and an address data is received. when the slave address and the address data do not correspond, h (nack) is automatically output. in case the slave device cannot receive owing to an interrupt process, performing operation or others, the master can output stop condition and complete data transfer by making the ack data of the slave address h for acknowledgment. even in case the slave device cannot receive a data during data transferring, the communication can be interrupted by performing nack acknowledgment to the following data. when the master is receiving the data from the slave, the master can notify the slave of completion of data reception by performing nack acknowledgment to the last data received from the slave. (5) restart condition the master can receive or transmit data without transmission of stop condition while the master is transmitting or receiving a data. for example, after the master transmitted a data to the slave, transmitting a slave address + r (read) following restart condition can make the following data treat as a reception data. additionally, transmitting a slave address + w (write) following restart condition can make the following data treat as a transmission data. fig. 2.4.12 restart condition of master reception 2.4.5 synchronization and arbitration lost (1) synchronization when a plural master exists on the i 2 c-bus and the masters, which have different speed, are going to simultaneously communicate; there is a rule to unify clocks so that a clock of each bit can be output correctly. figure 2.4.13 shows a synchronized scl line example. the scl (a) and the scl (b) are the master devices having a different speed. the scl is synchronized waveforms. as shown by figure 2.4.13, the scl lines can be synchronized by the following method; the device which first finishes h term makes the scl line l and the device which last remains l makes the scl line h. a sr a p r/w a r/w a a s start condition restart condition slave address 7 bits data 8 bits slave address 7 bits 8 bits 8 bits lower data upper data ?? ?? master reception 1st-byte master reception 2nd-byte master to slave slave to master nack expresses end of master reception data s: start condition a: ack bit sr: restart condition p: stop condition r/w: read/write bit write read
2-64 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface after start condition, the masters, which have different speed, simultaneously start clock transmission. the scl outputs l because (a) finished counting h output; then (b)s h output counting is interrupted and (b) starts counting l output. a the (a) outputs h because (a) finished counting l term; the scl level does not become h because (b) outputs l, and counting h term does not start but stop. ? (b) outputs l term. ? the scl outputs h because (b) finished counting l term; then (b)s h output counting is started at the same time as (a). ? the scl outputs l because (a) first finished counting h output; then (b)s h output counting is interrupted and (b) starts counting l output. ? the above are repeatedly performed. (2) clock synchronization during communication in the i 2 c-bus, the slave device is permitted to retain the scl line l and become waiting status for transmission from the master. by byte unit, for the reception preparation of the slave device, the master can become waiting status by making the scl line l, which is after completion of byte reception or the ack. by bit unit, it is possible to slow down a clock speed by retaining the scl line l for slave devices having limited hardware. the 3851 group can transmit data correctly without reduction of data bits toward waiting status request from the slave device. it is because the synchronization circuit is included for the case when retaining the scl line l as an internal hardware. after the last bit, including the ack bit, of a transmission/reception data byte, the scl line automatically remains l and waiting status is generated until completion of an interrupt process or reception preparation. (3) arbitration lost a plural master exists on the same bus in the i 2 c-bus and there are possibility to start communication simultaneously. even when the master devices having the same transmission frequency start communication simultaneously, which device must transmit data correctly. accordingly, there is the definition to detect a communication confliction on the sda line in the i 2 c-bus. the sda line is output at the timing synchronized by the scl, however, the synchronization among the sda signals is not performed. fig. 2.4.13 scl waveforms when synchronizing clocks scl(a) scl(b) scl a ? ? ? ?
3850/3851 group users manual application 2-65 2.4 multi-master i 2 c-bus interface 2.4.6 smbus communication usage example this clause explains a smbus communication control example using the i 2 c-bus. this is a control example as the master device and the slave device in the read word protocol of smbus protocol. the following is a communication example of the voltage () command of the smart battery data. communication specifications: ?communication frequency = 100 khz ?slave address of itself, battery, = 0001011x 2 (x means the read/write bit) ?slave address of communication destination, host, = 0001000x 2 (x means the read/write bit) ?voltage () command = 09 16 ?voltage value of acknowledgment = 2ee0 16 ; 12000 mv) ?the communication process is performed in the interrupt process. however, the main process performs an occurrence of the first start condition and a slave address set. ?a communication buffer is established. data transfer between the main process and the interrupt process is performed through the communication buffer. (1) initial setting figure 2.4.14 shows an initial setting example using smbus communication.
2-66 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface fig. 2.4.14 initial setting example using smbus communication s0d 1 00 10 1 0 b0 b7 0 s2 1 0 001 0 1 b0 b7 0 s1 01 0 b0 b7 s2d 01 b0 b7 000 1 1 s1d 0 10 b0 b7 000 1 0 0 i 2 c address register (address 2c 16 ) i 2 c clock control register (address 2f 16 ) i 2 c status register (address 2d 16 ) i 2 c start/stop condition control register (address 30 16 ) i 2 c control register (address 2e 16 ) set slave address value 16 16 set clock 100 khz (x in = 8mhz) standard clock mode ack is returned ack clock scl pin low hold bit: fix to ? slave receive mode set setup time hold time to 27 cycles (6.75 m s: x in = 8 mhz) scl/sda interrupt: falling edge active scl/sda interrupt: sda valid fix to ? set number of transmit/receive bits to ? i 2 c-bus interface: enabled addressing format 7-bit addressing format scl/sda:connect to ports p2 2 , p2 3 set smbus input level
3850/3851 group users manual application 2-67 2.4 multi-master i 2 c-bus interface (2) communication example in master device the master device follows the procedures to ? shown by figure 2.4.15. additionally, the shaded area in the figure is a transmission data from the master device and the white area is a transmission data from the slave device. generating of start condition; transmission of slave address + write bit transmission of command a generating of restart condition; transmission of slave address + read bit ? reception of lower data ? reception of upper data ? generating of stop condition figures 2.4.16 to 2.4.21 show the procedures to ? . fig. 2.4.15 read word protocol communication as smbus master device a sr a p r/w a r/w a a s a ? ? ? slave address 7 bits ? 8 bits 7 bits 8 bits 8 bits ? slave address command interrupt request interrupt request interrupt request interrupt request interrupt request lower data upper data master to slave slave to master s: start condition a: ack bit sr: restart condition p: stop condition r/w: read/write bit write read
2-68 3850/3851 group user? manual application 2.4 multi-master i 2 c-bus interface generating of start condition; transmission of slave address + write bit after confirming that other master devices do not use the bus, generate the start condition, because the smbus is a multi-master. write ?lave address + write bit?to the i 2 c data shift register (address 002b 16 ) before performing to make the start condition generate. it is because the scl of 1-byte unit is output, following occurrence of the start condition. if other master devices start communication until an occurrence of the start condition after confirming the bus use, it cannot communicate correctly. however in this case, that situation does not affect other master devices owing to detection of an arbitration lost or the start condition duplication preventing function. fig. 2.4.16 transmission process of start condition and slave address bb (address 2d 16 ), bit5 ? ( note 2 ) 0 (not used) 1 (used) end (a) ? 00010000 2 sei( note 1 ) s0(address 2b 16 ) ? (a) s1(address 2d 16 ) ? 11110000 2 cli( note 1 ) 1 ?interrupts disabled ?bus use confirmation ?start condition occurrence ?slave address value write ?interrupt enabled notes 1: in this example, the sei instruction to disable interrupts need not be executed because this processing is going to be performed in the interrupt processing. when the start condition is generated out of the interrupt processing, execute the sei instruction to disable interrupts. 2: use the branch bit instruction to confirm bus busy.
3850/3851 group users manual application 2-69 2.4 multi-master i 2 c-bus interface transmission of command confirm correct completion of communication at before command transmission. when receiving the stop condition, a process not to transmit a command is required, because the internal i 2 c- bus generates an interrupt request also owing to the stop condition transmitted to other devices. after confirming correct completion of communication, write a command to the i 2 c data shift register (address 002b 16 ). in case the al bit (bit 3 of address 002d 16 ) is 1, check the slave address comparison flag (ass bit; bit 2 of address 002d 16 ) to judge whether the device given a right of master transmission owing to an arbitration specifies itself as a slave address. when it is 1, perform the slave reception; when 0, wait for a stop condition occurrence caused by other devices and the communication completion. in case the al bit is 0, check the last received bit (lrb bit; bit 0 of address 002d 16 ). when it is 1, make the stop condition generate and release the bus use, because the specified slave device does not exist on the smbus. fig. 2.4.17 transmission process of command al (address 2d 16 ), bit 3 ? aas (address 2d 16 ), bit 2 ? 0(ack) 0(not detected) stop condition output s0(address 2b 16 ) ? 00001001 2 pin (address 2d 16 ), bit 4 ? 1(error) 0(slave address transmitted) lrb (address 2d 16 ), bit 0 ? 0(address not corresponded) 1(nack) 1(detected) 1(address corresponded) end 2 re-transmission preparation slave reception ?judgment of slave address comparison ?judgment of bus hold ?judgment of arbitration lost detection ?ack confirmation ?command data write to i 2 c data shift register
2-70 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface a generating of restart condition; transmission of slave address + read bit confirm correct completion of communication at before generating the restart condition. after confirming correct completion, generate the restart condition and perform the transmission process of slave address + read bit. note that procedure because that is different from s process. as the same reason as , write slave address + read bit to the i 2 c data shift register (address 002b 16 ) before performing to make the start condition generate. however, when writing a slave address to the i 2 c data shift register in this condition, a slave address is output at that time. consequently, the restart condition cannot be generated. therefore, follow the slave reception procedure before those processes. in case the arbitration lost detecting flag (al bit, bit 3 of address 002d 16 ) is 1, return to the process , because other master devices will have priority to communicate. when the last received bit (lrb bit; bit 0 of address 002d 16 ) is 1, generate the stop condition and make the bus release, because acknowledgment cannot be done owing to busy status of the slave device specified on the smbus or other reasons. fig. 2.4.18 transmission process of restart condition and slave address + read bit al (address 2d 16 ), bit 3 ? 0(not detected) 0(ack) s1(address 2d 16 ) ? 00000000 2 ( note 1 ) lrb (address 2d 16 ), bit 0 ? 1(nack) (a) ? 00010001 2 s0(address 002b 16 ) ? (a) s1(address 002d 16 ) ? 11110000 2 sei(note 2) end stop condition output re-transmission preparation 0(command transmission) pin (address 2d 16 ), bit 4 ? 3 cli( note 2 ) ?slave address value write ?bus judgment during hold ?judgment of arbitration lost detection ?ack confirmation ?slave receive mode set ?slave address read out ?interrupt disabled ?interrupt enabled ?restart condition occurrence 1 (stop condition) 1 (detected) notes 1: set to the receive mode while the pin bit is ?? do not write ??to the pin bit. 2: in this example, the sei instruction to disable interrupts need not be executed because this processing is going to be performed in the interrupt processing. when the start condition is generated out of the interrupt processing, execute the sei instruction to disable interrupts.
3850/3851 group user? manual application 2-71 2.4 multi-master i 2 c-bus interface ? reception of lower data confirm correct completion of communication at a before receiving the lower data. after confirming correct completion, clear the ack bit (bit 6 of address 002f 16 ) to ?? in which ack is returned and set to the master receive mode. after that, write a dummy data to the i 2 c data shift register (address 002b 16 ). when the mst bit (bit 7 of address 002d 16 ) is ?? perform the error process explained as follows and return to the process . when the last received bit (lrb bit; bit 0 of address 002d 16 ) is ?? generate the stop condition and make the bus release, because the slave device specified on the smbus does not exist. fig. 2.4.19 reception process of lower data 1(stop condition) al (address 2d 16 ), bit 3 ? mst (address 2d 16 ), bit 7 ? 0(ack) 1(master) s2(address 2f 16 ) ? 10000101 2 lrb (address 2d 16 ), bit0 ? 0(slave) 1(nack) 1(detected) 0(not detected) end re-transmission preparation error processing s1(address 2d 16 ) ? 10100000 2 s0(address 2b 16 ) ? 11111111 2 pin (address 2d 16 ), bit 4 ? 0(transmission of restart condition) ?master receive mode set 4 stop condition output ?judgment of bus hold ?judgment of arbitration lost detection ?ack confirmation ??ck clock is used?select and ?ck is returned?set ?judgment of slave mode detection ?dummy data to i 2 c data shift register write
2-72 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface ? transmission of upper data confirm correct completion of communication at ? before receiving the upper data. after confirming correct completion, store the received data (lower data). set the ack bit (bit 6 of address 002f 16 ) to 1, in which ack is not returned, write a dummy data to the i 2 c data shift register (address 002b 16 ). when the mst bit (bit 7 of address 002d 16 ) is 0, return to the process , because other devices have priority to communicate. fig. 2.4.20 reception process of upper data al (address 2d 16 ), bit 3 ? mst (address 2d 16 ), bit 7 ? 1(master) receive data buffer ? s0(address 2b 16 ) 0(slave) 1(detected) 0(not detected) end re-transmission preparation error processing s2(address 2f 16 ) ? 11000101 2 s0(address 2b 16 ) ? 11111111 2 pin (address 2d 16 ), bit 4 ? 1(stop condition) 0(lower data transmitted) 5 ?judgment of bus hold ?judgment of arbitration lost detection ??ack is returned?set ?judgment of slave mode detection ?dummy data to i 2 c data shift register write ?receive data read and save
3850/3851 group users manual application 2-73 2.4 multi-master i 2 c-bus interface ? generating of stop condition confirm correct completion of communication at ? before generating the stop condition. after confirming correct completion, store the received data (upper data). clear the ack bit (bit 6 of address 002f 16 ) to 0, in which ack is returned, generate the stop condition. the communication mode is set to the slave receive mode by the occurrence of stop condition. when the mst bit (bit 7 of address 002d 16 ) is 0, return to the process , because other devices have priority to communicate. fig. 2.4.21 generating of stop condition al (address 2d 16 ), bit 3 ? 1(detected) 0(not detected) s1(address 2d 16 ) ? 11010000 2 end re-transmission preparation receive data buffer ? s0(address 2b 16 ) s2(address 2f 16 ) ? 10000101 2 bb (address 2d 16 ), bit5 ? ( note ) 0(bus free) 1(bus busy) pin (address 2d 16 ), bit 4 ? 1(stop condition) 0(upper data transmitted) note: use the branch bit instruction to check bus busy. also, execute the time out processing separately, if neccessary. 6 ?judgment of bus hold ?judgment of arbitration lost detection ?set ?ck is returned ?judgment of bus busy ?stop condition occurrence ?receive data read and save
2-74 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface (3) communication example in slave device the slave device follows the procedures to ? shown by figure 2.4.22. the only difference from the master devices communication is an occurrence of interrupt request after detection of stop condition. reception of start condition; transmission of ack bit due to slave address correspondence reception of command a reception of restart condition; reception of slave address + read bit ? transmission of lower data ? transmission of upper data ? reception of stop condition figures 2.4.23 to 2.4.28 show the procedures to ? . fig. 2.4.22 communication example as smbus slave device a sr a p r/w a r/w a a s master to slave slave to master s: start condition a: ack bit sr: restart condition p: stop condition r/w: read/write bit a ? ?? slave address 7 bits ? 8 bits 7 bits 8 bits 8 bits ? slave address command interrupt request interrupt request interrupt request interrupt request interrupt request lower data upper data interrupt request write read
3850/3851 group users manual application 2-75 2.4 multi-master i 2 c-bus interface reception of start condition; transmission of ack bit due to slave address correspondence in the case of operation as the slave, all processes are performed in the interrupt after setting of the slave reception in the main process, because an interrupt request does not occur until correspondence of a slave address. in the first interrupt, after confirming correspondence of the slave address, write a dummy data to receive a command into the i 2 c data shift register. fig. 2.4.23 reception process of start condition and slave address aas (address 2d 16 ), bit 2 ? 1(corresponded) 0(not corresponded) end s0(address 2b 16 ) ? 11111111 2 error processing pin (address 2d 16 ), bit 4 ? 1(stop condition) 0(slave address received) 1 s1(address 2d 16 ) ? 00010000 2 ? judgment of bus hold ? judgment of slave address correspondence ? slave receive mode set ? dummy data write to i 2 c data shift register
2-76 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface reception of command confirm correct completion of the command reception in the interrupt after receiving the command. after confirming correct command from the host, write a dummy data to the i 2 c data shift register to wait for reception of the next slave address. fig. 2.4.24 reception process of command end s0(address 2b 16 ) ? 11111111 2 error end receive data buffer ? s0(address 2b 16 ) s2(address 2f 16 ) ? 10000101 2 judgment of receive command pin (address 2d 16 ), bit 4 ? 1(stop condition) 0(command received) 2 s1(address 2d 16 ) ? 00010000 2 ?judgment of bus hold ??ck clock is used?select and ?ck is returned?set ?slave receive mode set ?dummy data write to i 2 c data shift register ?receive data read and save
3850/3851 group users manual application 2-77 2.4 multi-master i 2 c-bus interface a reception of restart condition ane slave address + read bit after receiving a slave address, prepare a transmission data. judgment whether receiving a data or transmitting is required, because the mode is automatically switched between the receive mode and the transmit mode depending on the r/w bit of the received slave address. accordingly, judge whether read or write referring the slave address comparison flag (aas bit; bit 2 of address 002d 16 ). fig. 2.4.25 reception process of restart condition and slave address + read bit trx (address 2d 16 ), bit 6 ? 1(transmitted) 0(received) end s0(address 2b 16 ) ? lower data error end pin (address 2d 16 ), bit 4 ? 1(stop condition) 0 (lower data received) 3 s1(address 2d 16 ) ? 00010000 2 aas (address 2d 16 ), bit 2 ? 1(corresponded) 0(not corresponded) end slave receive processing, etc. ?judgment of bus hold ?judgment of transmit/receive mode ?slave receive mode set ?output lower data write to i 2 c data shift register
2-78 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface ? transmission of lower data before transmitting the upper data, restart to transmit the data at ? and confirm correct completion of transmission of the lower data set in the slave address reception interrupt. after that, transmit the upper data. fig. 2.4.26 transmission process of lower data end s0(address 2b 16 ) ? upper data error end 0(ack) lrb (address 2d 16 ), bit 0 ? 1(nack) pin (address 2d 16 ), bit 4 ? 1(stop condition) 0(lower data transmission completed) 4 s1(address 2d 16 ) ? 00010000 2 ?judgment of bus hold ?ack confirmation ?slave receive mode set ?output upper data write to i 2 c data shift register
3850/3851 group users manual application 2-79 2.4 multi-master i 2 c-bus interface ? transmission of upper data confirm correct completion of the upper data transmission. the master returns the nack toward the transmitted second-byte data, the upper data. accordingly, confirm that the last received bit (lrb bit; bit 0 of address 002d 16 ) is 1. after that, write a dummy data to the i 2 c data shift register (address 002b 16 ) and wait for the interrupt of stop condition. fig. 2.4.27 transmission process of upper data end s0(address 2b 16 ) ? 11111111 2 error end 0(ack) lrb (address 2d 16 ), bit 0 ? 1(nack) 5 pin (address 2d 16 ), bit 4 ? 1(stop condition) 0(upper data transmission completed) s1(address 2d 16 ) ? 00010000 2 note: use the branch bit instruction to check bus busy. ?judgment of bus hold ?ack confirmation ?slave receive mode set ?dummy data write to i 2 c data shift register
2-80 3850/3851 group users manual application 2.4 multi-master i 2 c-bus interface ? reception of stop condition confirm that the stop condition is correctly output and the bus is released. fig. 2.4.28 reception of stop condition end end processing s1(address 2d 16 ) ? 00010000 2 pin (address 2d 16 ), bit 4 ? 1(stop condition) 0(address or data received) error end 6 s1(address 2d 16 ) ? 00010000 2 ?judgment of bus hold ?slave receive mode set ?slave receive mode set
3850/3851 group users manual 2-81 application 2.4 multi-master i 2 c-bus interface 2.4.7 notes on multi-master i 2 c-bus interface (1) read-modify-write instruction each register of the multi-master i 2 c-bus interface has bits to change by hardware. the precautions when the read-modify-write instruction such as seb, clb etc. is executed for each register of the multi-master i 2 c-bus interface are described below. i 2 c data shift register (s0: address 002b 16 ) when executing the read-modify-write instruction for this register during transfer, data may become a value not intended. i 2 c address register (s0d: address 002c 16 ) when the read-modify-write instruction is executed for this register at detecting the stop condition, data may become a value not intended. l reason it is because hardware changes the read/write bit (rbw) at detecting the stop condition. a i 2 c status register (s1: address 002d 16 ) do not execute the read-modify-write instruction for this register because all bits of this register are changed by hardware. ? i 2 c control register (s1d: address 002e 16 ) when the read-modify-write instruction is executed for this register at detecting the start condition or at completing the byte transfer, data may become a value not intended. l reason because hardware changes the bit counter (bc0 to bc2). ? i 2 c clock control register (s2: address 002f 16 ) the read-modify-write instruction can be executed for this register. ? i 2 c start/stop condition control register (s2d: address 0030 16 ) the read-modify-write instruction can be executed for this register.
2-82 3850/3851 group users manual 2.4 multi-master i 2 c-bus interface application (2) start condition generating procedure using multi-master procedure example (the necessary conditions of the generating procedure are described as the following to ? . lda #sladr (taking out of slave address value) sei (interrupt disabled) bbs 5, s1, busbusy (bb flag confirming and branch process) busfree: sta s0 (writing of slave address value) ldm #$f0, s1 (trigger of start condition generating) cli (interrupt enabled) : : busbusy: cli (interrupt enabled) : : use branch on bit set of bbs 5, s1, C for the bb flag confirming and branch process. a use sta, stx or sty of the zero page addressing instruction for writing the slave address value to the i 2 c data shift register (s0: address 002b 16 ). ? execute the branch instruction of above 2 and the store instruction of above 3 continuously shown the above procedure example. ? disable interrupts during the following three process steps: ? bb flag confirming ? writing of slave address value ? trigger of start condition generating (3) restart condition generating procedure in master procedure example (the necessary conditions of the generating procedure are described as the following to ? ). execute the following procedure when the pin bit is 0. ldm #$00, s1 (select slave receive mode) lda #sladr (taking out of slave address value) sei (interrupt disabled) sta s0 (writing of slave address value) ldm #$f0, s1 (trigger of restart condition generating) cli (interrupt enabled) : : select the slave receive mode when the pin bit is 0. do not write 1 to the pin bit. neither 0 nor 1 is specified for the writing to the bb bit. the trx bit becomes 0 and the sda pin is released. a the scl pin is released by writing the slave address value to the i 2 c data shift register. ? disable interrupts during the following two process steps: ? writing of slave address value ? trigger of restart condition generating (4) writing to i 2 c status register do not execute an instruction to set the pin bit to 1 from 0 and an instruction to set the mst and trx bits to 0 from 1 simultaneously. it is because it may enter the state that the scl pin is released and the sda pin is released after about one machine cycle. do not execute an instruction to set the mst and trx bits to 0 from 1 simultaneously when the pin bit is 1. it is because it may become the same as above.
3850/3851 group users manual 2-83 application 2.4 multi-master i 2 c-bus interface (5) stop condition generating procedure in master procedure example (the necessary conditions of the generating procedure are described as the following to ? ). sei (interrupt disabled) ldm #$c0, s1 (select master transmit mode) nop (set nop) ldm #$d0, s1 (trigger of stop condition generating) cli (interrupt enabled) : : when setting the master transmit mode, write 0 to the pin bit. a execute the nop instruction after the master transmit mode is set. in addition, set the stop condition to be triggered within 10 machine cycles after the master transmit mode has been set. ? make sure all interrupts are disabled during the term from when the master transmit mode is set until the triggering process, which generates the stop condition, is complete. ? the above procedure is only applicable to the m38513e4. (6) process of after stop condition generating do not write data in the i 2 c data shift register s0 and the i 2 c status register s1 until the bus busy flag bb becomes 0 after generating the stop condition in the master mode. it is because the stop condition waveform might not be normally generated. reading to the above registers do not have the problem. (7) stop condition input at 7th clock pulse in the slave mode, the stop condition is input at the 7th clock pulse while receiving a slave address or data. as the clock pulse is continuously input, the sda line may be held at low even if flag bb is set to 0. countermeasure: write dummy data to the i 2 c shift register or reset the es0 bit in the s1d register (es0 = l ? es0 = h) during a stop condition interrupt routine with flag pin = 1. note: do not use the read-modify-write instruction at this time. furthermore, when the es0 bit is set to 0, it becomes a general-purpose port ; so that the port must be set to input mode or h. note: the m38514e6/m6 does not have this problem which is the sda line remaining l. (8) es0 bit switch in standard clock mode when ssc = 00010 2 or in high-speed clock mode, flag bb may switch to 1 if es0 bit is set to 1 when sda is l. countermeasure: set es0 to 1 when sda is h.
2-84 3850/3851 group users manual 2.4 multi-master i 2 c-bus interface application 2.4.8 notes on programming for smbus interface (1) time out process for a smart battery system, the time out process with a program is required so that the communication can be completed even when communication is interrupted. it is because there is possibility of extracting a battery from a pc. the specifications are defined so that communication has been able to be completed within 25 ms from start condition to stop condition and within 10 ms from the ack pulse from the ack pulse of each byte. accordingly, the following two should be considered as count start conditions. sda falling edge caused by scl/sda interrupt this is the countermeasure for a communication interrupt in the middle of from start condition to a slave address. however, the detection condition must be considered because a interrupt is also generated by communication from other masters to other slaves. smbus interrupt after receiving slave address this is the countermeasure for when communication is interrupted from receiving a slave address until receiving a command. (2) low hold of communication line the i2c-bus interface conforms to the i 2 c-bus standard specifications. however, because the use condition of smbus differs from the i 2 c-buss, there is possibility of occurrences of the following two problems. low hold of sda line caused by ack pulse at voltage drop of communication line when the smbus voltage slowly drops, that is caused by extracting a battery from equipment or turning off a pcs power or etc., it might be incorrectly treated as the scl pulse near the threshold level voltage. when the sda is judged l in that condition, it becomes the general call and the ack is transmitted. however, when the scl remains l at the ack pulse, the sda continuously remains l until input of the next scl pulse. countermeasure: as explained before, start the time out count at the falling of sda line of start condition and reset es0 bit of the s1d register when the time out is satisfied ( note ). stop condition input at 7th clock pulse in the slave mode, the stop condition is input at the 7th clock pulse while receiving a slave address or data. as the clock pulse is continuously input, the sda line may be held at l even if flag bb is set to 0. countermeasure: write dummy data to the i 2 c shift register or reset the es0 bit in the s1d register (es0 = l ? es0 = h) during a stop condition interrupt routine with flag pin = 1. note: do not use the read-modify-write instruction at this time. furthermore, when the es0 bit is set to 0, it becomes a general-purpose port ; so that the port must be set to input mode or h. note: the m38514e6/m6 does not have this problem which is the sda line remaining l.
3850/3851 group user's manual application 2-85 2.5 pwm 2.5 pwm this paragraph explains the registers setting method and the notes relevant to the pwm. 2.5.1 memory map 2.5.2 related registers 001d 16 001e 16 001f 16 pwm control register (pwmcon) pwm prescaler (prepwm) pwm register (pwm) fig. 2.5.1 memory map of registers relevant to pwm fig. 2.5.2 structure of pwm control register pwm control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 pwm control register(pwmcon) [address : 1d 16 ] pwm function enable bit 0: pwm disabled 1: pwm enabled count source selection bit 0: f(x in ) 1: f(x in )/2 nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the valeu are 0. 5 5 5 5 5 5
3850/3851 group user's manual application 2-86 2.5 pwm fig. 2.5.3 structure of pwm prescaler fig. 2.5.4 structure of pwm register pwm register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name ? ? ? ? ? ? ? ? pwm register (pwm) [address : 1f 16 ] ? set a h level output period of pwm. ? the values set in this register is written to both the pwm register pre-latch and the pwm register latch at the same time. ? when data is written during pwm outputting , the pulses corresponding to the changed contents are output starting at the next cycle. ? when this register is read out, the contents of the pwm register latch is read out. pwm prescaler b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name ? ? ? ? ? ? ? ? pwm prescaler (prepwm) [address : 1e 16 ] ? set a pwm period. ? the values set in this register is written to both the pwm prescaler pre-latch and the pwm prescaler latch at the same time. ? when data is written during pwm outputting, the pulses corresponding to the changed contents are output starting at the next cycle. ? when this register is read out, the contents of the pwm prescaler latch is read out.
3850/3851 group user's manual application 2-87 2.5 pwm 2.5.3 pwm output circuit application example outline : the rotation speed of the motor is controlled by using pwm (pulse width modulation) output. figure 2.5.5 shows a connection diagram ; figures 2.5.6 shows pwm output timing, and figure 2.5.7 shows a setting of the related registers. p4 4 /pwm 3851 group d-a converter motor driver m fig. 2.5.5 connection diagram specifications : ? motor is controlled by using the pwm output function of 8-bit resolution. ? clock f(x in ) = 5.0 mhz ? t, pwm cycle : 102 s ? t, h level width of output pulse : 40 s (fixed speed) ] a motor speed can be changed by modifying the h level width of output pulse. fig. 2.5.6 pwm output timing pwm output t = 40 s t = 102 s
3850/3851 group user's manual application 2-88 2.5 pwm fig. 2.5.7 setting of related registers 1 pwm function enable bit : pwm enabled (note) pwmcon pwm control register (address : 1d 16 ) 255 5 (n + 1) set t, pwm cycle n = 1 prepwm pwm prescaler (address : 1e 16 ) note : the pwm output function has priority even when bit 4 (corresponding bit to p4 4 pin) of port p4 direction register is set to 0 (input mode). b7 b0 0 count source selection bit : f(x in ) b7 b0 n [equation] t = set t, h level width of pwm m = 100 pwm pwm register (address : 1f 16 ) b7 b0 m [equation] t = f(x in ) t 5 m 255 1. set the pwm function enable bit to 1 : the p4 4 /pwm pin is used as the pwm pin. the pulse beginning with h level pulse is output. 2. set the pwm function enable bit to 0 : the p4 4 /pwm pin is used as the port p4 4 . thus, when fixing the output level, take the following procedure: (1) write an output value to bit 4 of the port p4 register. (2) write 0001000 2 to the port p4 direction register. 3. after data is set to the pwm prescaler and the pwm register, the pwm waveforms corresponding to updated data will be output from the next repetitive cycle. fig. 2.5.8 pwm output pwm output change pwm output data from the next repetitive cycle, output modified data
3850/3851 group user's manual application 2-89 2.5 pwm control procedure : by setting the related registers as shown by figure 2.5.7, pwm waveforms are output to the externals. this pwm output is integrated through the low pass filter, and that converted into dc signals is used for control of the motor. figure 2.5.9 shows control procedure. p4 (address : 08 16 ), bit4 p4d (address : 09 16 ) ~ ~ prepwm (address : 1e 16 ) pwm (address : 1f 16 ) pwmcon (address : 1d 16 ) ? l level output from p4 4 /pwm pin 0 xxx1xxxx 2 1 100 xxxxxx01 2 ? set the pwm period. ? set the h level width of pwm. ? select the pwm count source, and enable the pwm output. ? x : this bit is not used here. set it to 0 or 1 arbitrarily. ~ ~ fig. 2.5.9 control procedure 2.5.4 notes on pwm the pwm starts after the pwm enable bit is set to enable and l level is output from the pwm pin. the length of this l level output is as follows: sec. (count source selection bit = 0, where n is the value set in the prescaler) sec. (count source selection bit = 1, where n is the value set in the prescaler) n + 1 2 ? f(x in ) n + 1 f(x in )
2-90 3850/3851 group users manual application 2.6 a-d converter 2.6 a-d converter this paragraph explains the registers setting method and the notes relevant to the a-d converter. 2.6.1 memory map fig. 2.6.1 memory map of registers relevant to a-d converter 2.6.2 relevant registers 0034 16 0035 16 0036 16 003d 16 a-d control register (adcon) a-d conversion register (low-order); (adl) a-d conversion register (high-order); (adh) interrupt request register 2 (ireq2) 003f 16 interrupt control register 2 (icon2) b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 1 0 0 a-d control register (adcon) [address : 34 16 ] nothing is allocated for this bit. this is a write disabled bit. when this bit is read out, the value is 0. 5 a-d control register 0 0 0 0 : p3 0 /an 0 0 0 1 : p3 1 /an 1 0 1 0 : p3 2 /an 2 0 1 1 : p3 3 /an 3 1 0 0 : p3 4 /an 4 1 0 1 : p3 5 /an 5 1 1 0 : p3 6 /an 6 1 1 1 : p3 7 /an 7 analog input pin selection bits b2 b1 b0 0 0 ad conversion completion bit 0 : conversion in progress 1 : conversion completed nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. 0 5 5 5 fig. 2.6.2 structure of a-d control register
3850/3851 group users manual application 2-91 2.6 a-d converter a-d conversion register (high-order) b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name ? ? ? ? ? ? ? ? the read-only register in which the a-d conversions results are stored. 5 5 5 5 5 5 5 5 < 10-bit read> b7 b9 b0 b8 nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. a-d conversion register (high-order) (adh) [address : 36 ] 16 fig. 2.6.3 structure of a-d conversion register (high-order) fig. 2.6.4 structure of a-d conversion register(low-order) a-d conversion register (low-order) b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 ? ? ? ? ? ? ? ? a-d conversion register (low-order) (adl) [address : 35 ] the read-only register in which the a-d conversions results are stored. 5 5 5 5 5 5 5 5 < 8-bit read> b7 b8 b7 b6 b5 b4 b3 b0 b2 b9 < 10-bit read> b7 b6 b5 b4 b3 b2 b1 b0 b0 b7 16
2-92 3850/3851 group users manual application 2.6 a-d converter interrupt request register 2 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt request register 2 (ireq2) [address : 3d 16 ] nothing is allocated for this bit. this is a write disabled bit. when this bit is read out, the value is 0. 5 timer 1 interrupt request bit timer 2 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued cntr 1 interrupt request bit ad converter interrupt request bit ] : these bits can be cleared to 0 by program, but cannot be set to 1. 0 : no interrupt request issued 1 : interrupt request issued serial i/o receive interrupt request bit serial i/o transmit interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued cntr 0 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued ] ] ] ] ] ] ] fig. 2.6.5 structure of interrupt request register 2 interrupt control register 2 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt control register 2 (icon2) [address : 3f 16 ] fix this bit to 0. timer 1 interrupt enable bit timer 2 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled cntr 1 interrupt enable bit ad converter interrupt enable bit serial i/o receive interrupt enable bit serial i/o transmit interrupt enable bit cntr 0 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 fig. 2.6.6 structure of interrupt control register 2
3850/3851 group users manual application 2-93 2.6 a-d converter 2.6.3 a-d converter application examples (1) conversion of analog input voltage outline : the analog input voltage input from a sensor is converted to digital values. figure 2.6.7 shows a connection diagram, and figure 2.6.8 shows the relevant registers setting. fig. 2.6.7 connection diagram p3 0 /an 0 3851 group sensor specifications : ?the analog input voltage input from a sensor is converted to digital values. ?p3 0 /an 0 pin is used as an analog input pin. a-d control register (address 34 16 ) adcon 0 analog input pin : p3 0 /an 0 selected a-d conversion start 0 0 0 b0 b7 a-d conversion register (high-order); (address 36 16 ) adh adl b0 b7 b0 b7 (read-only) a-d conversion register (low-order); (address 35 16 ) (read-only) a result of a-d conversion is stored ( note ). note : after bit 4 of adcon is set to 1, read out that contents. when reading 10-bit data, read address 0036 16 before address 0035 16 ; when reading 8-bit data, read address 0035 16 only. fig. 2.6.8 relevant registers setting
2-94 3850/3851 group users manual application 2.6 a-d converter an analog input signal from a sensor is converted to the digital value according to the relevant registers setting shown by figure 2.6.8. figure 2.6.9 shows the control procedure for 8-bit read, and figure 2.6.10 shows the control procedure for 10-bit read. adcon (address 34 16 ), bit2 C bit0 adcon (address 34 16 ), bit4 000 2 0 read out adl (address 35 16 ) adcon (address 34 16 ), bit4 ? 1 0 ?p3 0 /an 0 pin selected as analog input pin ?a-d conversion start ?judgment of a-d conversion completion ?read out of conversion result adcon (address 34 16 ), bit2 ?bit0 adcon (address 34 16 ), bit4 000 2 0 read out adh (address 36 16 ) adcon (address 34 16 ), bit4 ? 1 0 ?3 0 /an 0 pin selected as analog input pin ?-d conversion start ?udgment of a-d conversion completion ?ead out of high-order digit (b9, b8) of conversion result read out adl (address 35 16 ) ?ead out of low-order digit (b7 ?b0) of conversion result fig. 2.6.9 control procedure for 8-bit read fig. 2.6.10 control procedure for 10-bit read
3850/3851 group users manual application 2-95 2.6 a-d converter 2.6.4 notes on a-d converter (1) analog input pin make the signal source impedance for analog input low, or equip an analog input pin with an external capacitor of 0.01 m f to 1 m f. further, be sure to verify the operation of application products on the user side. l reason an analog input pin includes the capacitor for analog voltage comparison. accordingly, when signals from signal source with high impedance are input to an analog input pin, charge and discharge noise generates. this may cause the a-d conversion precision to be worse. (2) a-d converter power source pin pins av cc and av ss are a-d converter power source pins. regardless of using the a-d conversion function or not, connect them as following : ? av cc : connect to the v cc line ? av ss : connect to the v ss line l reason if the a vcc and the av ss pin are opened, the microcomputer may have a failure because of noise or others. also, if the av cc pin is connected to the v ss pin, current flows from av cc to v ss . (3) clock frequency during a-d conversion the comparator consists of a capacity coupling, and a charge of the capacity will be lost if the clock frequency is too low. thus, make sure the following during an a-d conversion. ? f(x in ) is 500 khz or more ? do not execute the stp instruction and wit instruction
2-96 application 3850/3851 group users manual 2.7 reset v cc reset 1 5 reset int cd v cc 1 v cc 2 v1 gnd 2 6 3 7 m62009l,m62009p,m62009fp 4 int 0 v ss system power source voltage +5 v + 3851 group 2.7 reset 2.7.1 connection example of reset ic fig. 2.7.1 example of poweron reset circuit figure 2.7.2 shows the system example which switches to the ram backup mode by detecting a drop of the system power source voltage with the int interrupt. v cc reset v ss m62022l gnd 1 3 4 5 0.1 m f power source output delay capacity 3851 group fig. 2.7.2 ram backup system
3850/3851 group users manual 2-97 application 2.7 reset 2.7.2 notes on reset pin connecting capacitor in case where the reset signal rise time is long, connect a ceramic capacitor or others across the reset pin and the v ss pin. use a 1000 pf or more capacitor for high frequency use. when connecting the capacitor, note the following : ? make the length of the wiring which is connected to a capacitor as short as possible. ? be sure to verify the operation of application products on the user side. l reason if the several nanosecond or several ten nanosecond impulse noise enters the reset pin, it may cause a microcomputer failure.
2-98 application 3850/3851 group users manual 2.7 reset memorandum
chapter 3 chapter 3 appendix 3.1 electrical characteristics 3.2 standard characteristics 3.3 notes on use 3.4 countermeasures against noise 3.5 list of registers 3.6 mask rom confirmation form 3.7 rom programming confirmation form 3.8 mark specification form 3.9 package outline 3.10 machine instructions 3.11 list of instruction codes 3.12 sfr memory map 3.13 pin configurations
3850/3851 group users manual appendix 3.1 electrical characteristics 3-2 input voltage p0 0 Cp0 7 , p1 0 Cp1 7 , p2 0 , p2 1, p2 4 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 , v ref input voltage p2 2 , p2 3 input voltage reset, x in input voltage cnv ss output voltage p0 0 Cp0 7 , p1 0 Cp1 7 , p2 0 , p2 1, p2 4 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 , x out output voltage p2 2 , p2 3 power dissipation operating temperature storage temperature v i v i v i v i v o 3.1 electrical characteristics 3.1.1 absolute maximum ratings table 3.1.1 absolute maximum ratings power source voltage v cc symbol parameter conditions ratings C0.3 to 7.0 C0.3 to 6.5 v unit t a = 25 c all voltages are based on v ss . output transistors are cut off. m38513e4/m4 m38514e6 m38514m6 v o p d t opr t stg C0.3 to v cc +0.3 C0.3 to 5.8 C0.3 to v cc +0.3 C0.3 to 13 C0.3 to v cc +0.3 C0.3 to 5.8 300 C20 to 85 C40 to 125 v v v v v v mw c c
3850/3851 group users manual appendix 3-3 3.1 electrical characteristics v cc v ss v ref av ss v ia v ih v ih v ih v ih v ih v ih v il v il v il v il v il 5.5 5.5 v cc v cc v cc 5.8 v cc 5.8 v cc v cc 0.2v cc 0.3v cc 0.6 0.2v cc 0.16v cc power source voltage (at 8 mhz) power source voltage (at 4 mhz) power source voltage a-d convert reference voltage analog power source voltage analog input voltage an 0 Can 4 h input voltage p0 0 Cp0 7 , p1 0 Cp1 7 , p2 0 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 h input voltage (when i 2 c-bus input level is selected) s da1 , s cl1 h input voltage (when i 2 c-bus input level is selected) s da2 , s cl2 h input voltage (when smbus input level is selected) s da1 , s cl1 h input voltage (when smbus input level is selected) s da2 , s cl2 h input voltage reset, x in , cnv ss l input voltage p0 0 Cp0 7 , p1 0 Cp1 7 , p2 0 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 l input voltage (when i 2 c-bus input level is selected) s da1 , s da2 , s cl1 , s cl2 l input voltage (when smbus input level is selected) s da1 , s da2 , s cl1 , s cl2 l input voltage reset, cnv ss l input voltage x in symbol parameter limits min. v v v v v v v v v v v v v v v v unit table 3.1.2 recommended operating conditions (1) (v cc = 2.7 to 5.5 v, t a = C20 to 85 c, unless otherwise noted) 4.0 2.7 2.0 av ss 0.8v cc 0.7v cc 0.7v cc 1.4 1.4 0.8v cc 0 0 0 0 0 5.0 5.0 0 0 typ. max. C80 C80 80 80 120 80 C40 C40 40 40 60 40 h total peak output current p0 0 Cp0 7 , p1 0 Cp1 7 , p3 0 Cp3 4 (note) h total peak output current p2 0 , p2 1 , p2 4 Cp2 7 , p4 0 Cp4 4 (note) l total peak output current p0 0 Cp0 7 , p1 0 Cp1 2 , p3 0 Cp3 4 (m38513e4/m4) (note) p0 0 Cp0 7 , p3 0 Cp3 4 (m38514e6/m6) l total peak output current p1 3 Cp1 7 (m38513e4/m4) (note) p1 0 Cp1 7 (m38514e6/m6) l total peak output current p2 0 Cp2 7 ,p4 0 Cp4 4 (note) h total average output current p0 0 Cp0 7 , p1 0 Cp1 7 , p3 0 Cp3 4 (note) h total average output current p2 0 , p2 1 , p2 4 Cp2 7 , p4 0 Cp4 4 (note) l total average output current p0 0 Cp0 7 , p1 0 Cp1 2 , p3 0 Cp3 4 (m38513e4/m4) (note) p0 0 Cp0 7 , p3 0 Cp3 4 (m38514e6/m6) l total average output current p1 3 Cp1 7 (m38513e4/m4) (note) p1 0 Cp1 7 (m38514e6/m6) l total average output current p2 0 Cp2 7 ,p4 0 Cp4 4 (note) s i oh(peak) s i oh(peak) s i ol(peak) s i ol(peak) s i ol(peak) s i oh(avg) s i oh(avg) s i ol(avg) s i ol(avg) s i ol(avg) ma ma ma ma ma ma ma ma ma ma ma ma 3.1.2 recommended operating conditions note : the total output current is the sum of all the currents flowing through all the applicable ports. the total average current is an average value measured over 100 ms. the total peak current is the peak value of all the currents.
3850/3851 group users manual appendix 3.1 electrical characteristics 3-4 table 3.1.3 recommended operating conditions (2) (v cc = 2.7 to 5.5 v, t a = C20 to 85 c, unless otherwise noted) C10 10 20 C5 5 15 8 4 h peak output current p0 0 Cp0 7 , p1 0 Cp1 7 , p2 0 , p2 1 , p2 4 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 (note 1) l peak output current p0 0 Cp0 7 , p1 0 Cp1 2 , p2 0 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 (note 1) (m38513e4/m4) p0 0 Cp0 7 , p2 0 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 (m38514e6/m6) l peak output current p1 3 Cp1 7 (m38513e4/m4) (note 1) p1 0 Cp1 7 (m38514e6/m6) h average output current p0 0 Cp0 7 , p1 0 Cp1 7 , p2 0 , p2 1 , p2 4 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 (note 2) l average output current p0 0 Cp0 7 , p1 0 Cp1 2 , p2 0 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 (note 2) (m38513e4/m4) p0 0 Cp0 7 , p2 0 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 (m38514e6/m6) l peak output current p1 3 Cp1 7 (m38513e4/m4) (note 2) p1 0 Cp1 7 (m38514e6/m6) internal clock oscillation frequency (v cc = 4.0 to 5.5v) (note 3) internal clock oscillation frequency (v cc = 2.7 to 5.5v) (note 3) i oh(peak) i ol(peak) i ol(peak) i oh(avg) i ol(avg) i ol(avg) f(x in ) f(x in ) symbol parameter limits min. ma ma ma ma ma ma mhz mhz unit typ. max. notes 1: the peak output current is the peak current flowing in each port. 2: the average output current i ol (avg), i oh (avg) are average value measured over 100 ms. 3: when the oscillation frequency has a duty cycle of 50%.
3850/3851 group users manual appendix 3-5 3.1 electrical characteristics table 3.1.4 electrical characteristics (1) (v cc = 2.7 to 5.5 v, v ss = 0 v, t a = C20 to 85 c, unless otherwise noted) h output voltage p0 0 Cp0 7 , p1 0 Cp1 7 , p2 0 , p2 1, p2 4 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 (note) l output voltage p0 0 Cp0 7 , p1 0 Cp1 2 , p2 0 Cp2 7 p3 0 Cp3 4 , p4 0 Cp4 4 (m38513e4/m4) l output voltage p0 0 Cp0 7 , p2 0 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 (m38514e6/m6) l output voltage p1 3 Cp1 7 (m38513e4/m4) l output voltage p1 0 Cp1 7 (m38514e6/m6) hysteresis cntr 0 , cntr 1 , int 0 Cint 3 hysteresis rxd, s clk , s da1 , s da2 , s cl1 , s cl2 hysteresis reset h input current p0 0 Cp0 7 , p1 0 Cp1 7 , p2 0 , p2 1, p2 4 Cp2 7 , p3 0 Cp3 4 , p4 0 Cp4 4 h input current reset, cnv ss h input current x in l input current p0 0 Cp0 7 , p1 0 Cp1 7 , p2 0 Cp2 7 p3 0 Cp3 4 , p4 0 Cp4 4 l input current reset,cnv ss l input current x in ram hold voltage limits v v v v v v v v v v v v v m a m a m a m a m a m a v parameter min. typ. max. symbol unit note: p2 5 is measured when the p2 5 /t x d p-channel output disable bit of the uart control register (bit 4 of address 001b 16 ) is 0. i oh = C10 ma v cc = 4.0C5.5 v i oh = C1.0 ma v cc = 2.7C5.5 v i ol = 10 ma v cc = 4.0C5.5 v i ol = 1.0 ma v cc = 2.7C5.5 v i ol = 10 ma v cc = 4.0C5.5 v i ol = 1.0 ma v cc = 2.7C5.5 v i ol = 20 ma v cc = 4.0C5.5 v i ol = 10 ma v cc = 2.7C5.5 v i ol = 20 ma v cc = 4.0C5.5 v i ol = 10 ma v cc = 2.7C5.5 v v i = v cc v i = v cc v i = v cc v i = v ss v i = v ss v i = v ss when clock stopped v cc C2.0 v cc C1.0 test conditions 0.4 0.5 0.5 2.0 1.0 2.0 1.0 2.0 1.0 2.0 1.0 v oh v ol v ol v ol v ol v t+ Cv tC v t+ Cv tC v t+ Cv tC i ih i ih i ih i il i il i il v ram 2.0 3.1.3 electrical characteristics 5.0 5.0 4 C4 C5.0 C5.0 5.5
3850/3851 group users manual appendix 3.1 electrical characteristics 3-6 table 3.1.5 electrical characteristics (2) (v cc = 2.7 to 5.5 v, v ss = 0 v, t a = C20 to 85 c, unless otherwise noted) power source current limits parameter min. typ. max. symbol unit high-speed mode f(x in ) = 8 mhz f(x cin ) = 32.768 khz output transistors off high-speed mode f(x in ) = 8 mhz (in wit state) f(x cin ) = 32.768 khz output transistors off low-speed mode f(x in ) = stopped f(x cin ) = 32.768 khz output transistors off low-speed mode f(x in ) = stopped f(x cin ) = 32.768 khz (in wit state) output transistors off low-speed mode (v cc = 3 v) f(x in ) = stopped f(x cin ) = 32.768 khz output transistors off low-speed mode (v cc = 3 v) f(x in ) = stopped f(x cin ) = 32.768 khz (in wit state) output transistors off middle-speed mode f(x in ) = 8 mhz f(x cin ) = stopped output transistors off middle-speed mode f(x in ) = 8 mhz (in wit state) f(x cin ) = stopped output transistors off increment when a-d conversion is executed f(x in ) = 8 mhz test conditions 13 i cc ta = 25 c ta = 85 c 6.8 ma all oscillation stopped (in stp state) output transistors off 1.6 60 20 20 5.0 4.0 1.5 800 0.1 200 40 55 10.0 7.0 1.0 10 ma m a m a m a m a ma ma m a m a m a bit lsb tc( f ) m s k w m a m a resolution absolute accuracy (excluding quantization error) conversion time ladder resistor reference power source input current a-d port input current min. 50 ty p . 40 35 150 0.5 max. 10 4 61 200 5.0 v ref = 5.0 v table 3.1.6 a-d converter characteristics (v cc = 2.7 to 5.5 v, v ss = av ss = 0 v, t a = C20 to 85 c, f(x in ) = 8 mhz, unless otherwise noted) unit limits parameter C C t conv r ladder i vref i i(ad) test conditions symbol 3.1.4 a-d converter characteristics high-speed mode, middle-speed mode low-speed mode (note) note: only m38514e6/m6 can operate the a-d conversion at low-speed mode.
3850/3851 group users manual appendix 3-7 3.1 electrical characteristics table 3.1.7 timing requirements (1) (v cc = 4.0 to 5.5 v, v ss = 0 v, t a = C20 to 85 c, unless otherwise noted) reset input l pulse width external clock input cycle time external clock input h pulse width external clock input l pulse width cntr 0 , cntr 1 input cycle time cntr 0 , cntr 1 , int 0 Cint 3 input h pulse width cntr 0 , cntr 1 , int 0 Cint 3 input l pulse width serial i/o clock input cycle time (note) serial i/o clock input h pulse width (note) serial i/o clock input l pulse width (note) t w (reset) t c (x in ) t wh (x in ) t wl (x in ) t c (cntr) t wh (cntr) t wl (cntr) t c (s clk ) t wh (s clk ) t wl (s clk ) t su (r x d-s clk ) t h (s clk -r x d) limits m s ns ns ns ns ns ns ns ns ns ns ns parameter min. 2 125 50 50 200 80 80 800 370 370 220 100 typ. max. symbol unit note : when f(x in ) = 8 mhz and bit 6 of address 001a 16 is 1 (clock synchronous). divide this value by four when f(x in ) = 8 mhz and bit 6 of address 001a 16 is 0 (uart). serial i/o input setup time serial i/o input hold time table 3.1.8 timing requirements (2) (v cc = 2.7 to 5.0 v, v ss = 0 v, t a = C20 to 85 c, unless otherwise noted) reset input l pulse width external clock input cycle time external clock input h pulse width external clock input l pulse width cntr 0 , cntr 1 input cycle time cntr 0 , cntr 1 , int 0 Cint 3 input h pulse width cntr 0 , cntr 1 , int 0 Cint 3 input l pulse width serial i/o clock input cycle time (note) serial i/o clock input h pulse width (note) serial i/o clock input l pulse width (note) serial i/o input setup time serial i/o input hold time t w (reset) t c (x in ) t wh (x in ) t wl (x in ) t c (cntr) t wh (cntr) t wl (cntr) t c (s clk ) t wh (s clk ) t wl (s clk ) t su (r x d-s clk ) t h (s clk -r x d) limits m s ns ns ns ns ns ns ns ns ns ns ns parameter min. 2 250 100 100 500 230 230 2000 950 950 400 200 typ. max. symbol unit note : when f(x in ) = 8 mhz and bit 6 of address 001a 16 is 1 (clock synchronous). divide this value by four when f(x in ) = 8 mhz and bit 6 of address 001a 16 is 0 (uart). 3.1.5 timing requirements
3850/3851 group users manual appendix 3.1 electrical characteristics 3-8 table 3.1.9 switching characteristics (1) (v cc = 4.0 to 5.5 v, v ss = 0 v, t a = C20 to 85 c, unless otherwise noted) serial i/o clock output h pulse width serial i/o clock output l pulse width serial i/o output delay time (note 1) serial i/o output valid time (note 1) serial i/o clock output rising time serial i/o clock output falling time cmos output rising time (note 2) cmos output falling time (note 2) t wh (s clk ) t wl (s clk ) t d (s clk -t x d) t v (s clk -t x d) t r (s clk ) t f (s clk ) t r (cmos) t f (cmos) limits ns ns ns ns ns ns ns ns parameter parameter test conditions test conditions min. t fig. 3.1.1 fig. 3.1.1 c (s clk )/2C30 t c (s clk )/2C30 C30 ty p . 10 10 max. 140 30 30 30 30 symbol unit notes 1: for t wh (s clk ), t wl (s clk ), when the p2 5 /t x d p-channel output disable bit of the uart control register (bit 4 of address 001b 16 ) is 0. 2: the x out pin is excluded. table 3.1.10 switching characteristics (2) (v cc = 2.7 to 4.0 v, v ss = 0 v, t a = C20 to 85 c, unless otherwise noted) serial i/o clock output h pulse width serial i/o clock output l pulse width serial i/o output delay time (note 1) serial i/o output valid time (note 1) serial i/o clock output rising time serial i/o clock output falling time cmos output rising time (note 2) cmos output falling time (note 2) t wh (s clk ) t wl (s clk ) t d (s clk -t x d) t v (s clk -t x d) t r (s clk ) t f (s clk ) t r (cmos) t f (cmos) limits ns ns ns ns ns ns ns ns min. t c (s clk )/2C50 t c (s clk )/2C50 C30 ty p . 20 20 max. 350 50 50 50 50 symbol unit notes 1: for t wh (s clk ), t wl (s clk ), when the p2 5 /t x d p-channel output disable bit of the uart control register (bit 4 of address 001b 16 ) is 0. 2: the x out pin is excluded. 3.1.6 switching characteristics
3850/3851 group users manual appendix 3-9 3.1 electrical characteristics n-channel open-drain output measurement output pin 100pf 1k w measurement output pin 100pf cmos output fig. 3.1.1 circuit for measuring output switching characteris- tics (1) fig. 3.1.2 circuit for measuring output switching characteris- tics (2)
3850/3851 group users manual appendix 3.1 electrical characteristics 3-10 fig. 3.1.3 timing diagram 0.2v cc t wl(int) 0.8v cc t wh(int) 0.2v cc 0.2v cc 0.8v cc 0.8v cc 0.2v cc t wl(x in ) 0.8v cc t wh(x in) t c(x in ) x in 0.2v cc 0.8v cc t w(reset) reset t f t r 0.2v cc t wl(cntr) 0.8v cc t wh(cntr) t c(cntr) t d(s clk -t x d) t v(s clk -t x d) t c(s clk ) t wl(s clk ) t wh(s clk ) t h(s clk- r x d) t su(r x d - s clk ) t x d r x d s clk int 0 to int 3 cntr 0 , cntr 1
3850/3851 group users manual appendix 3-11 3.1 electrical characteristics symbol parameter unit table 3.1.11 multi-master i 2 c-bus bus line characteristics bus free time hold time for start condition hold time for s cl clock = 0 rising time of both s cl and s da signals data hold time hold time for s cl clock = 1 falling time of both s cl and s da signals data setup time setup time for repeated start condition setup time for stop condition t buf t hd;sta t low t r t hd;dat t high t f t su;dat t su;sta t su;sto min. max. min. max. m s m s m s ns m s m s ns ns m s m s standard clock mode high-speed clock mode note: c b = total capacitance of 1 bus line fig. 3.1.4 timing diagram of multi-master i 2 c-bus 4.7 4.0 4.7 0 4.0 250 4.7 4.0 1000 300 1.3 0.6 1.3 20+0.1c b 0 0.6 20+0.1c b 100 0.6 0.6 300 0.9 300 3.1.7 multi-master i 2 c-bus bus line characteristics t buf t hd:sta t hd:dat t low t r t f t high t su:dat t su:sta t hd:sta t su:sto s cl p s sr p s da s : start condition sr : restart condition p : stop condition
3850/3851 group users manual appendix 3.2 standard characteristics 3-12 3.2 standard characteristics 3.2.1 power source current characteristic examples figures 3.2.1, figures 3.2.2, figures 3.2.3, figures 3.2.3, figures 3.2.4 and figures 3.2.5 show power source current characteristic examples. fig. 3.2.1 power source current characteristic examples (f(x in ) = 8mhz, in high-speed mode) fig. 3.2.2 power source current characteristic examples (f(x in ) = 8mhz, in middle-speed mode) 2.0 0.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 1.0 2.0 3.0 4.0 5.0 6.0 7.0 [measuring condition : 25 c, f(x in ) = 8mhz, in high-speed mode] power source current (ma) standard mode wait mode power source voltage (v) 2.0 0.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 0.5 1.0 1.5 2.0 2.5 3.0 3.5 [measuring condition : 25 c, f(x in ) = 8mhz, in middle-speed mode] power source current (ma) standard mode wait mode power source voltage (v)
3850/3851 group users manual appendix 3-13 3.2 standard characteristics fig. 3.2.3 power source current characteristic examples (f(x in ) = 4mhz, in high-speed mode) fig. 3.2.4 power source current characteristic examples (f(x in ) = 4mhz, in middle-speed mode) 2.0 0.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 0.2 0.4 0.6 0.8 1.0 1.2 1.4 [measuring condition : 25 c, f(x in ) = 4mhz, in middle-speed mode] power source current (ma) standard mode wait mode power source voltage (v) 2.0 0.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 0.5 1.0 1.5 2.0 2.5 3.0 3.5 [measuring condition : 25 c, f(x in ) = 4mhz, in high-speed mode] power source current (ma) standard mode wait mode power source voltage (v)
3850/3851 group users manual appendix 3.2 standard characteristics 3-14 fig. 3.2.5 power source current characteristic examples (f(x cin ) = 32khz, in low-speed mode) 2.0 0.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 10 20 30 40 50 60 70 [measuring condition : 25 c, f(x cin ) = 32khz, in low-speed mode] power source current ( m a) standard mode wait mode power source voltage (v)
3850/3851 group users manual appendix 3-15 3.2 standard characteristics 3.2.2 port standard characteristic examples figures 3.2.6, figures 3.2.7, figures 3.2.8 and figures 3.2.9 show port standard characteristic examples. fig. 3.2.6 standard characteristic examples of cmos output port at p-channel drive fig. 3.2.7 standard characteristic examples of cmos output port at n-channel drive 0 v oh [v] i oh [ma] 0.5 0 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 C5 C10 C15 C20 C25 C30 C35 C40 C45 C50 vcc = 4.0v 5.5 vcc = 5 v vcc = 2.7v port p2 0 i oh Cv oh characteristic (p-channel drive) (pins with same characteristic : p0,p1,p2 1 ,p2 4 Cp2 7 ,p3,p4) 0 v ol [v] i ol [ma] 0.5 0 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 10 20 30 40 50 60 70 80 90 100 vcc = 4.0v 5.5 vcc = 5v vcc = 2.7v port p2 0 i ol Cv ol characteristic (n-channel drive) (pins with same characteristic : p0,p1,p2 1 ,p2 4 Cp2 7 ,p3,p4)
3850/3851 group users manual appendix 3.2 standard characteristics 3-16 fig. 3.2.8 standard characteristic examples of n-channel open-drain output port at n-channel drive fig. 3.2.9 standard characteristic examples of cmos large current output port at n-channel drive 0 v ol [v] i ol [ma] 0.5 0 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 10 20 30 40 50 60 70 80 90 100 vcc = 4.0v 5.5 vcc = 5v vcc = 2.7v port p2 2 i ol C v ol characteristic (n-channel drive) (n-channel open-drain output: pins with same characteristic : p2 3 ) 0 v ol [v] i ol [ma] 0.5 0 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 10 20 30 40 50 60 70 80 90 100 vcc = 4.0v 5.5 vcc = 5v vcc = 2.7v port p1 3 i ol Cv ol characteristic (n-channel drive) (large current output port: pins with same characteristic : p1 4 Cp1 7 for m38513e4/m4; p1 0 Cp1 2 and p1 4 Cp1 7 for m38514e6/m6)
3850/3851 group users manual appendix 3-17 3.2 standard characteristics 3.2.3 a-d conversion standard characteristics figure 3.2.10 shows the a-d conversion standard characteristics. the lower-side line on the graph indicates the absolute precision error. it represents the deviation from the ideal value. for example, the conversion of output code from 0 to 1 occurs ideally at the point of an 0 = 2.5 mv, but the measured value is C4 mv. accordingly, the measured point of conversion is represented as 2.5 C 4 = C1.5 mv. the upper-side line on the graph indicates the width of input voltages equivalent to output codes. for example, the measured width of the input voltage for output code 96 is 5 mv, so the differential nonlinear error is represented as 5 C 5 = 0 mv (0 lsb). fig. 3.2.10 a-d conversion standard characteristics 15 10 5 -5 -10 -15 0 error [mv] step no. 0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 256 0.0 5.0 10.0 15.0 1lsb width [mv] 15 10 5 -5 -10 -15 0 error [mv] step no. 256 0.0 5.0 10.0 15.0 1lsb width [mv] 272 288 304 320 336 352 368 384 400 416 432 448 464 480 496 512 15 10 5 -5 -10 -15 0 error [mv] step no. 512 0.0 5.0 10.0 15.0 1lsb width [mv] 528 544 560 576 592 606 624 640 656 672 688 704 720 736 752 768 15 10 5 -5 -10 -15 0 error [mv] step no. 768 0.0 5.0 10.0 15.0 1lsb width [mv] 784 800 816 832 848 864 880 896 912 928 944 960 976 992 1008 1024 3851 grup a-d converter error & step width measurement v cc =5.12 [v], v ref =5.12 [v] x in =8 [mhz], temp=25 [deg.] absolute precision error 1lsb width
3-18 appendix 3850/3851 group users manual 3.3 notes on use 3.3.1 notes on interrupts (1) setting of interrupt request bit and interrupt enable bit to set an interrupt request bit and an interrupt enable bit for interrupts, execute as the following sequence : clear an interrupt request bit to 0 (no interrupt request issued). set an interrupt enable bit to 1 (interrupts enabled). l reason if the above setting , are performed simultaneously with one instruction, an unnecessary interrupt processing routine is executed. because an interrupt enable bit is set to 1 (interrupts enabled) before an interrupt request bit is cleared to 0. (2) switching external interrupt detection edge when switching the external interrupt detection edge, switch it as the following sequence. clear an interrupt enable bit to 0 (interrupt disabled) switch the detection edge clear an interrupt request bit to 0 (no interrupt request issued) set the interrupt enable bit to 1 (interrupt enabled) 3.3 notes on use fig. 3.3.1 sequence of switch the detection edge l reason the interrupt circuit recognizes the switching of the detection edge as the change of external input signals. this may cause an unnecessary interrupt. (3) check of interrupt request bit when executing the bbc or bbs instruction to an interrupt request bit of an interrupt request register immediately after this bit is set to 0 by using a data transfer instruction, execute one or more instructions before executing the bbc or bbs instruction. clear the interrupt request bit to 0 (no interrupt issued) nop (one or more instructions) execute the bbc or bbs instruction data transfer instruction: ldm, lda, sta, stx, and sty instructions l reason if the bbc or bbs instruction is executed immediately after an interrupt request bit of an interrupt request register is cleared to 0, the value of the interrupt request bit before being cleared to 0 is read. fig. 3.3.2 sequence of check of interrupt request bit
3850/3851 group users manual 3-19 appendix 3.3 notes on use 3.3.3 notes on serial i/o (1) notes when selecting clock synchronous serial i/o stop of transmission operation clear the serial i/o enable bit and the transmit enable bit to 0 (serial i/o and transmit disabled). l reason since transmission is not stopped and the transmission circuit is not initialized even if only the serial i/o enable bit is cleared to 0 (serial i/o disabled), the internal transmission is running (in this case, since pins txd, rxd, s clk , and s rdy function as i/o ports, the transmission data is not output). when data is written to the transmit buffer register in this state, data starts to be shifted to the transmit shift register. when the serial i/o enable bit is set to 1 at this time, the data during internally shifting is output to the txd pin and an operation failure occurs. stop of receive operation clear the receive enable bit to 0 (receive disabled), or clear the serial i/o enable bit to 0 (serial i/o disabled). a stop of transmit/receive operation clear both the transmit enable bit and receive enable bit to 0 (transmit and receive disabled) at the same time. (when data is transmitted and received in the clock synchronous serial i/o mode, any one of data transmission and reception cannot be stopped.) l reason in the clock synchronous serial i/o mode, the same clock is used for transmission and reception. if any one of transmission and reception is disabled, a bit error occurs because transmission and reception cannot be synchronized. in this mode, the clock circuit of the transmission circuit also operates for data reception. accordingly, the transmission circuit does not stop by clearing only the transmit enable bit to 0 (transmit disabled). also, the transmission circuit is not initialized by clearing the serial i/o enable bit to 0 (serial i/o disabled) (refer to (1) ). 3.3.2 notes on timer l if a value n (between 0 and 255) is written to a timer latch, the frequency division ratio is 1/(n+1). l when switching the count source by the timer 12, x and y count source selection bit, the value of timer count is altered in unconsiderable amount owing to generating of a thin pulses in the count input signals. therefore, select the timer count source before set the value to the prescaler and the timer.
3-20 appendix 3850/3851 group users manual 3.3 notes on use (2) notes when selecting clock asynchronous serial i/o stop of transmission operation clear the transmit enable bit to 0 (transmit disabled). l reason since transmission is not stopped and the transmission circuit is not initialized even if only the serial i/o enable bit is cleared to 0 (serial i/o disabled), the internal transmission is running (in this case, since pins txd, rxd, s clk , and s rdy function as i/o ports, the transmission data is not output). when data is written to the transmit buffer register in this state, data starts to be shifted to the transmit shift register. when the serial i/o enable bit is set to 1 at this time, the data during internally shifting is output to the txd pin and an operation failure occurs. stop of receive operation clear the receive enable bit to 0 (receive disabled). a stop of transmit/receive operation only transmission operation is stopped. clear the transmit enable bit to 0 (transmit disabled). l reason since transmission is not stopped and the transmission circuit is not initialized even if only the serial i/o enable bit is cleared to 0 (serial i/o disabled), the internal transmission is running (in this case, since pins txd, rxd, s clk , and s rdy function as i/o ports, the transmission data is not output). when data is written to the transmit buffer register in this state, data starts to be shifted to the transmit shift register. when the serial i/o enable bit is set to 1 at this time, the data during internally shifting is output to the txd pin and an operation failure occurs. only receive operation is stopped. clear the receive enable bit to 0 (receive disabled). (3) s rdy output of reception side when signals are output from the s rdy pin on the reception side by using an external clock in the clock synchronous serial i/o mode, set all of the receive enable bit, the s rdy output enable bit, and the transmit enable bit to 1 (transmit enabled). (4) setting serial i/o control register again set the serial i/o control register again after the transmission and the reception circuits are reset by clearing both the transmit enable bit and the receive enable bit to 0. fig. 3.3.3 sequence of setting serial i/o control register again clear both the transmit enable bit (te) and the receive enable bit (re) to 0 set the bits 0 to 3 and bit 6 of the serial i/o control register set both the transmit enable bit (te) and the receive enable bit (re), or one of them to 1 can be set with the ldm instruction at the same time
3850/3851 group users manual 3-21 appendix 3.3 notes on use (5) data transmission control with referring to transmit shift register completion flag the transmit shift register completion flag changes from 1 to 0 with a delay of 0.5 to 1.5 shift clocks. when data transmission is controlled with referring to the flag after writing the data to the transmit buffer register, note the delay. (6) transmission control when external clock is selected when an external clock is used as the synchronous clock for data transmission, set the transmit enable bit to 1 at h of the s clk input level. also, write the transmit data to the transmit buffer register (serial i/o shift register) at h of the s clk input level. (7) transmit interrupt request when transmit enable bit is set the transmission interrupt request bit is set and the interruption request is generated even when selecting timing that either of the following flags is set to 1 as timing where the transmission interruption is generated. ? transmit buffer empty flag is set to 1 ? transmit shift register completion flag is set to 1 therefore, when the transmit interrupt is used, set the transmit interrupt enable bit to transmit enabled as the following sequence. transmit enable bit is set to 1 transmit interrupt request bit is set to 0 l reason when the transmission enable bit is set to 1, the transmit buffer empty flag and transmit shift register completion flag are set to 1. 3.3.4 notes on multi-master i 2 c-bus interface (1) read-modify-write instruction each register of the multi-master i 2 c-bus interface has bits to change by hardware. the precautions when the read-modify-write instruction such as seb, clb etc. is executed for each register of the multi-master i 2 c-bus interface are described below. i 2 c data shift register (s0: address 002b 16 ) when executing the read-modify-write instruction for this register during transfer, data may become a value not intended. i 2 c address register (s0d: address 002c 16 ) when the read-modify-write instruction is executed for this register at detecting the stop condition, data may become a value not intended. l reason it is because hardware changes the read/write bit (rbw) at detecting the stop condition. a i 2 c status register (s1: address 002d 16 ) do not execute the read-modify-write instruction for this register because all bits of this register are changed by hardware. ? i 2 c control register (s1d: address 002e 16 ) when the read-modify-write instruction is executed for this register at detecting the start condition or at completing the byte transfer, data may become a value not intended. l reason because hardware changes the bit counter (bc0 to bc2). ? i 2 c clock control register (s2: address 002f 16 ) the read-modify-write instruction can be executed for this register. ? i 2 c start/stop condition control register (s2d: address 0030 16 ) the read-modify-write instruction can be executed for this register.
3-22 appendix 3850/3851 group users manual (2) start condition generating procedure using multi-master procedure example (the necessary conditions of the generating procedure are described as the following to ? . lda #sladr (taking out of slave address value) sei (interrupt disabled) bbs 5, s1, busbusy (bb flag confirming and branch process) busfree: sta s0 (writing of slave address value) ldm #$f0, s1 (trigger of start condition generating) cli (interrupt enabled) : : busbusy: cli (interrupt enabled) : : use branch on bit set of bbs 5, s1, C for the bb flag confirming and branch process. a use sta, stx or sty of the zero page addressing instruction for writing the slave address value to the i 2 c data shift register (s0: address 002b 16 ). ? execute the branch instruction of above 2 and the store instruction of above 3 continuously shown the above procedure example. ? disable interrupts during the following three process steps: ? bb flag confirming ? writing of slave address value ? trigger of start condition generating (3) restart condition generating procedure in master procedure example (the necessary conditions of the generating procedure are described as the following to ? ). execute the following procedure when the pin bit is 0. ldm #$00, s1 (select slave receive mode) lda #sladr (taking out of slave address value) sei (interrupt disabled) sta s0 (writing of slave address value) ldm #$f0, s1 (trigger of restart condition generating) cli (interrupt enabled) : : select the slave receive mode when the pin bit is 0. do not write 1 to the pin bit. neither 0 nor 1 is specified for the writing to the bb bit. the trx bit becomes 0 and the sda pin is released. a the scl pin is released by writing the slave address value to the i 2 c data shift register. ? disable interrupts during the following two process steps: ? writing of slave address value ? trigger of restart condition generating (4) writing to i 2 c status register do not execute an instruction to set the pin bit to 1 from 0 and an instruction to set the mst and trx bits to 0 from 1 simultaneously. it is because it may enter the state that the scl pin is released and the sda pin is released after about one machine cycle. do not execute an instruction to set the mst and trx bits to 0 from 1 simultaneously when the pin bit is 1. it is because it may become the same as above. 3.3 notes on use
3850/3851 group users manual 3-23 appendix 3.3 notes on use (5) stop condition generating procedure in master procedure example (the necessary conditions of the generating procedure are described as the following to ? ). sei (interrupt disabled) ldm #$c0, s1 (select master transmit mode) nop (set nop) ldm #$d0, s1 (trigger of stop condition generating) cli (interrupt enabled) : : when setting the master transmit mode, write 0 to the pin bit. a execute the nop instruction after the master transmit mode is set. in addition, set the stop condition to be triggered within 10 machine cycles after the master transmit mode has been set. ? make sure all interrupts are disabled during the term from when the master transmit mode is set until the triggering process, which generates the stop condition, is complete. ? the above procedure is only applicable to the m38513e4. (6) process of after stop condition generating do not write data in the i 2 c data shift register s0 and the i 2 c status register s1 until the bus busy flag bb becomes 0 after generating the stop condition in the master mode. it is because the stop condition waveform might not be normally generated. reading to the above registers do not have the problem. (7) stop condition input at 7th clock pulse in the slave mode, the stop condition is input at the 7th clock pulse while receiving a slave address or data. as the clock pulse is continuously input, the sda line may be held at low even if flag bb is set to 0. countermeasure: write dummy data to the i 2 c shift register or reset the es0 bit in the s1d register (es0 = l ? es0 = h) during a stop condition interrupt routine with flag pin = 1. notes 1: do not use the read-modify-write instruction at this time. furthermore, when the es0 bit is set to 0, it becomes a general-purpose port ; so that the port must be set to input mode or h. 2: the m38514e6/m6 does not have this problem which is the sda line remaining l. (8) es0 bit switch in standard clock mode when ssc = 00010 2 or in high-speed clock mode, flag bb may switch to 1 if es0 bit is set to 1 when sda is l. countermeasure: set es0 to 1 when sda is h.
3-24 appendix 3850/3851 group users manual 3.3 notes on use 3.3.5 notes on a-d converter (1) analog input pin make the signal source impedance for analog input low, or equip an analog input pin with an external capacitor of 0.01 m f to 1 m f. further, be sure to verify the operation of application products on the user side. l reason an analog input pin includes the capacitor for analog voltage comparison. accordingly, when signals from signal source with high impedance are input to an analog input pin, charge and discharge noise generates. this may cause the a-d conversion precision to be worse. (2) a-d converter power source pin pins av cc and av ss are a-d converter power source pins. regardless of using the a-d conversion function or not, connect them as following : ? av cc : connect to the v cc line ? av ss : connect to the v ss line l reason if the a vcc and the av ss pin are opened, the microcomputer may have a failure because of noise or others. also, if the av cc pin is connected to the v ss pin, current flows from av cc to v ss . (3) clock frequency during a-d conversion the comparator consists of a capacity coupling, and a charge of the capacity will be lost if the clock frequency is too low. thus, make sure the following during an a-d conversion. ? f(x in ) is 500 khz or more ? do not execute the stp instruction and wit instruction 3.3.6 notes on watchdog timer l the watchdog timer continues counting even while waiting for the stop release. make sure the watchdog timer does not underflow during this term. l once the stp instruction inhibit bit of the watchdog timer control register is set to 1, the bit can not be reprogrammed to 0. 3.3.7 notes on reset pin (1) connecting capacitor in case where the reset signal rise time is long, connect a ceramic capacitor or others across the reset pin and the v ss pin. and use a 1000 pf or more capacitor for high frequency use. when connecting the capacitor, note the following : ? make the length of the wiring which is connected to a capacitor as short as possible. ? be sure to verify the operation of application products on the user side. l reason if the several nanosecond or several ten nanosecond impulse noise enters the reset pin, it may cause a microcomputer failure.
3850/3851 group users manual 3-25 appendix 3.3 notes on use 3.3.8 notes on input and output pins (1) notes in stand-by state in stand-by state* 1 for low-power dissipation, do not make input levels of an input port and an i/o port undefined, especially for i/o ports of the p-channel and the n-channel open-drain. pull-up (connect the port to v cc ) or pull-down (connect the port to v ss ) these ports through a resistor. when determining a resistance value, note the following points: ? external circuit ? variation of output levels during the ordinary operation when using built-in pull-up or pull-down resistor, note on varied current values: ? when setting as an input port : fix its input level ? when setting as an output port : prevent current from flowing out to external l reason even when setting as an output port with its direction register, in the following state : ? p-channel......when the content of the port latch is 0 ? n-channel......when the content of the port latch is 1 the transistor becomes the off state, which causes the ports to be the high-impedance state. note that the level becomes undefined depending on external circuits. accordingly, the potential which is input to the input buffer in a microcomputer is unstable in the state that input levels of a input port and an i/o port are undefined. this may cause power source current. * 1 stand-by state : the stop mode by executing the stp instruction the wait mode by executing the wit instruction (2) modifying output data with bit managing instruction when the port latch of an i/o port is modified with the bit managing instruction* 2 , the value of the unspecified bit may be changed. l reason the bit managing instructions are read-modify-write form instructions for reading and writing data by a byte unit. accordingly, when these instructions are executed on a bit of the port latch of an i/o port, the following is executed to all bits of the port latch. ? as for a bit which is set for an input port : the pin state is read in the cpu, and is written to this bit after bit managing. ? as for a bit which is set for an output port : the bit value of the port latch is read in the cpu, and is written to this bit after bit managing. note the following : ? even when a port which is set as an output port is changed for an input port, its port latch holds the output data. ? as for a bit of the port latch which is set for an input port, its value may be changed even when not specified with a bit managing instruction in case where the pin state differs from its port latch contents. * 2 bit managing instructions : seb , and clb instructions
3-26 appendix 3850/3851 group users manual 3.3 notes on use 3.3.9 notes on low-speed operation mode (1) using sub-clock to use a sub-clock, fix the bit 3 of the cpu mode register to 1 (xcout drive capacity is high) and control the rd (refer to figure 3.3.4) resistance value to a certain level to stabilize an oscillation. for resistance value of rd, consult the oscillator manufacturer. l reason when the bit 3 of cpu mode register is set to 0, the sub-clock oscillation may stop. 3.3.10 notes on restarting oscillation (1) restarting oscillation usually, when the mcu stops the clock oscillation by stp instruction and the stp instruction has been released by an external interrupt source, the fixed values of timer 1 and prescaler 12 (timer 1 = 01 16 , prescaler 12 = ff 16 ) are automatically reloaded in order for the oscillation to stabilize. the user can inhibit the automatic setting by writing 1 to bit 0 of misrg (address 0038 16 ). however, by setting this bit to 1, the previous values, set just before the stp instruction was executed, will remain in timer 1 and prescaler 12. therefore, you will need to set an appropriate value to each register, in accordance with the oscillation stabilizing time, before executing the stp instruction. l reason oscillation will restart when an external interrupt is received. however, internal clock phi is supplied to the cpu only when timer 1 starts to underflow. this ensures time for the clock oscillation using the ceramic resonators to be stabilized. fig. 3.3.4 ceramic resonator circuit r d c cin c cout x cin x cout r f
3850/3851 group users manual 3-27 appendix 3.3.11 notes on programming (1) processor status register initializing of processor status register flags which affect program execution must be initialized after a reset. in particular, it is essential to initialize the t and d flags because they have an important effect on calculations. l reason after a reset, the contents of the processor status register (ps) are undefined except for the i flag which is 1. reset initializing of flags main program fig. 3.3.7 stack memory contents after php instruction execution plp instruction execution nop how to reference the processor status register to reference the contents of the processor status register (ps), execute the php instruction once then read the contents of (s+1). if necessary, execute the plp instruction to return the ps to its original status. a nop instruction should be executed after every plp instruction. fig. 3.3.5 initialization of processor status register fig. 3.3.6 sequence of plp instruction execution 3.3 notes on use (s) (s)+1 stored ps
3-28 appendix 3850/3851 group users manual 3.3 notes on use (2) brk instruction detection of interrupt source it can be detected that the brk instruction interrupt event or the least priority interrupt event by referring the stored b flag state. refer to the stored b flag state in the interrupt routine. interrupt priority level when the brk instruction is executed with the following conditions satisfied, the interrupt execution is started from the address of interrupt vector which has the highest priority. ? interrupt request bit and interrupt enable bit are set to 1. ? interrupt disable flag (i) is set to 1 to disable interrupt. (3) decimal calculations execution of decimal calculations the adc and sbc are the only instructions which will yield proper decimal notation, set the decimal mode flag (d) to 1 with the sed instruction. after executing the adc or sbc instruction, execute another instruction before executing the sec , clc , or cld instruction. notes on status flag in decimal mode when decimal mode is selected, the values of three of the flags in the status register (the n, v, and z flags) are invalid after a adc or sbc instruction is executed. the carry flag (c) is set to 1 if a carry is generated as a result of the calculation, or is cleared to 0 if a borrow is generated. to determine whether a calculation has generated a carry, the c flag must be initialized to 0 before each calculation. to check for a borrow, the c flag must be initialized to 1 before each calculation. fig. 3.3.8 interrupt routine (s) (s)+1 pc l (low-order of program counter) 74 0 1 =b frag pc h (high-order of program counter) ps (4) jmp instruction when using the jmp instruction in indirect addressing mode, do not specify the last address on a page as an indirect address. set d flag to 1 adc or sbc instruction nop instruction sec , clc , or cld instruction fig. 3.3.9 status flag at decimal calculations
3850/3851 group users manual 3-29 appendix fig. 3.3.10 programming and testing of one time prom version 3.3.12 programming and test of built-in prom version as for in the one time prom version (shipped in blank) and the built-in eprom version, their built-in prom can be read or programmed with a general-purpose prom programmer using a special programming adapter. the built-in eprom version is available only for program development and on-chip program evaluation. the programming test and screening for prom of the one time prom version (shipped in blank) are not performed in the assembly process and the following processes. to ensure reliability after programming, performing programming and test according to the figure 3.3.10 before actual use are recommended. 3.3.13 notes on built-in prom version (1) programming adapter use a special programming adapter shown in table 3.3.2 and a general-purpose prom programmer when reading from or programming to the built-in prom in the built-in prom version. table 3.3.1 programming adapters m38513e4ss m38514e6ss m38513e4sp (one time prom version shipped in blank) m38514e6sp (one time prom version shipped in blank) m38513e4fp (one time prom version shipped in blank) m38514e6fp (one time prom version shipped in blank) pca4738s-42a pca4738f-42a programming adapter microcomputer 3.3 notes on use programming with prom programmer screening (caution) (leave at 150 ? for 40 hours) verification with prom programmer functional check in target device caution: the screening temperature is far higher than the storage temperature. never expose to 150 ? exceeding 100 hours.
3-30 appendix 3850/3851 group users manual (2) programming/reading in prom mode, operation is the same as that of the m5m27c101ak, but programming conditions of prom programmer are not set automatically because there are no internal device id codes. accurately set the following conditions for data programming /reading. take care not to apply 21 v to v pp pin (is also used as the cnv ss pin), or the product may be permanently damaged. ? programming voltage: 12.5 v ? setting of prom programmer switch: refer to table 3.3.3. product name format prom programmer start address address 0c080 16 ( note 1 ) address 0a080 16 ( note 2 ) prom programmer end address m38513e4ss m38513e4sp m38513e4fp m38514e6ss m38514e6sp m38514e6fp table 3.3.2 prom programmer address setting address 0fffd 16 ( note 1 ) address 0fffd 16 ( note 2 ) notes 1: addresses c080 16 to fffd 16 in the built-in prom corresponds to addresses 0c080 16 to 0fffd 16 in the prom programmer. 2: addresses a080 16 to fffd 16 in the built-in prom corresponds to addresses 0a080 16 to 0fffd 16 in the prom programmer. (3) erasing contents of the windowed eprom are erased through an ultraviolet light source of the wavelength 2537 ?ngstrom. at least 15 w ? sec/cm are required to erase eprom contents. 3.3 notes on use
3850/3851 group users manual 3-31 appendix 3.3.14 termination of unused pins (1) terminate unused pins output ports : open input ports : connect each pin to v cc or v ss through each resistor of 1 k w to 10 k w . as for pins whose potential affects to operation modes such as pins cnv ss , int or others, select the v cc pin or the v ss pin according to their operation mode. a i/o ports : ? set the i/o ports for the input mode and connect them to v cc or v ss through each resistor of 1 k w to 10 k w . set the i/o ports for the output mode and open them at l or h. ? when opening them in the output mode, the input mode of the initial status remains until the mode of the ports is switched over to the output mode by the program after reset. thus, the potential at these pins is undefined and the power source current may increase in the input mode. with regard to an effects on the system, thoroughly perform system evaluation on the user side. ? since the direction register setup may be changed because of a program runaway or noise, set direction registers by program periodically to increase the reliability of program. (2) termination remarks input ports and i/o ports : do not open in the input mode. l reason ? the power source current may increase depending on the first-stage circuit. ? an effect due to noise may be easily produced as compared with proper termination and a shown on the above. i/o ports : when setting for the input mode, do not connect to v cc or v ss directly. l reason if the direction register setup changes for the output mode because of a program runaway or noise, a short circuit may occur between a port and v cc (or v ss ). a i/o ports : when setting for the input mode, do not connect multiple ports in a lump to v cc or v ss through a resistor. l reason if the direction register setup changes for the output mode because of a program runaway or noise, a short circuit may occur between ports. ? at the termination of unused pins, perform wiring at the shortest possible distance (20 mm or less) from microcomputer pins. 3.3 notes on use
3-32 appendix 3850/3851 group users manual fig. 3.4.2 wiring for the reset pin 3.4 countermeasures against noise 3.4 countermeasures against noise countermeasures against noise are described below. the following countermeasures are effective against noise in theory, however, it is necessary not only to take measures as follows but to evaluate before actual use. 3.4.1 shortest wiring length the wiring on a printed circuit board can function as an antenna which feeds noise into the microcomputer. the shorter the total wiring length (by mm unit), the less the possibility of noise insertion into a microcomputer. (1) package select the smallest possible package to make the total wiring length short. l reason the wiring length depends on a microcomputer package. use of a small package, for example qfp and not dip, makes the total wiring length short to reduce influence of noise. fig. 3.4.1 selection of packages (2) wiring for reset pin make the length of wiring which is connected to the reset pin as short as possible. especially, connect a capacitor across the reset pin and the v ss pin with the shortest possible wiring (within 20mm). l reason the width of a pulse input into the reset pin is determined by the timing necessary conditions. if noise having a shorter pulse width than the standard is input to the reset pin, the reset is released before the internal state of the microcomputer is completely initialized. this may cause a program runaway. dip sdip sop qfp reset reset circuit noise v ss v ss reset circuit v ss reset v ss n.g. o.k.
3850/3851 group users manual 3-33 appendix (3) wiring for clock input/output pins ? make the length of wiring which is connected to clock i/o pins as short as possible. ? make the length of wiring (within 20mm) across the grounding lead of a capacitor which is connected to an oscillator and the v ss pin of a microcomputer as short as possible. ? separate the v ss pattern only for oscillation from other v ss patterns. l reason if noise enters clock i/o pins, clock waveforms may be deformed. this may cause a program failure or program runaway. also, if a potential difference is caused by the noise between the v ss level of a microcomputer and the v ss level of an oscillator, the correct clock will not be input in the microcomputer. fig. 3.4.3 wiring for clock i/o pins (4) wiring to cnv ss pin connect the cnv ss pin to the v ss pin with the shortest possible wiring. l reason the processor mode of a microcomputer is influenced by a potential at the cnv ss pin. if a potential difference is caused by the noise between pins cnv ss and v ss , the processor mode may become unstable. this may cause a microcomputer malfunction or a program runaway. fig. 3.4.4 wiring for cnv ss pin 3.4 countermeasures against noise noise x in x out v ss x in x out v ss n.g. o.k. noise cnv ss v ss cnv ss v ss n.g. o.k.
3-34 appendix 3850/3851 group users manual (5) wiring to v pp pin of one time prom version and eprom version connect an approximately 5 k w resistor to the v pp pin the shortest possible in series and also to the v ss pin. when not connecting the resistor, make the length of wiring between the v pp pin and the v ss pin the shortest possible. note: even when a circuit which included an approximately 5 k w resistor is used in the mask rom version, the microcomputer operates correctly. l reason the v pp pin of the one time prom and the eprom version is the power source input pin for the built-in prom. when programming in the built-in prom, the impedance of the v pp pin is low to allow the electric current for writing flow into the prom. because of this, noise can enter easily. if noise enters the v pp pin, abnormal instruction codes or data are read from the built-in prom, which may cause a program runaway. fig. 3.4.5 wiring for the v pp pin of the one time prom and the eprom version 3.4.2 connection of bypass capacitor across v ss line and v cc line connect an approximately 0.1 m f bypass capacitor across the v ss line and the v cc line as follows: ? connect a bypass capacitor across the v ss pin and the v cc pin at equal length. ? connect a bypass capacitor across the v ss pin and the v cc pin with the shortest possible wiring. ? use lines with a larger diameter than other signal lines for v ss line and v cc line. ? connect the power source wiring via a bypass capacitor to the v ss pin and the v cc pin. fig. 3.4.6 bypass capacitor across the v ss line and the v cc line 3.4 countermeasures against noise cnv ss /v pp v ss in the shortest distance approximately 5k w v ss v cc v ss v cc n.g. o.k.
3850/3851 group users manual 3-35 appendix 3.4.3 wiring to analog input pins ? connect an approximately 100 w to 1 k w resistor to an analog signal line which is connected to an analog input pin in series. besides, connect the resistor to the microcomputer as close as possible. ? connect an approximately 1000 pf capacitor across the v ss pin and the analog input pin. besides, connect the capacitor to the v ss pin as close as possible. also, connect the capacitor across the analog input pin and the v ss pin at equal length. l reason signals which is input in an analog input pin (such as an a-d converter/comparator input pin) are usually output signals from sensor. the sensor which detects a change of event is installed far from the printed circuit board with a microcomputer, the wiring to an analog input pin is longer necessarily. this long wiring functions as an antenna which feeds noise into the microcomputer, which causes noise to an analog input pin. if a capacitor between an analog input pin and the vss pin is grounded at a position far away from the vss pin, noise on the gnd line may enter a microcomputer through the capacitor. fig. 3.4.7 analog signal line and a resistor and a capacitor 3.4.4 oscillator concerns take care to prevent an oscillator that generates clocks for a microcomputer operation from being affected by other signals. (1) keeping oscillator away from large current signal lines install a microcomputer (and especially an oscillator) as far as possible from signal lines where a current larger than the tolerance of current value flows. l reason in the system using a microcomputer, there are signal lines for controlling motors, leds, and thermal heads or others. when a large current flows through those signal lines, strong noise occurs because of mutual inductance. fig. 3.4.8 wiring for a large current signal line 3.4 countermeasures against noise analog input pin v ss noise thermistor microcomputer n.g. o.k. (note) note : the resistor is used for dividing resistance with a thermistor. x in x out v ss m microcomputer mutual inductance large current gnd
3-36 appendix 3850/3851 group users manual (2) installing oscillator away from signal lines where potential levels change frequently install an oscillator and a connecting pattern of an oscillator away from signal lines where potential levels change frequently. also, do not cross such signal lines over the clock lines or the signal lines which are sensitive to noise. l reason signal lines where potential levels change frequently (such as the cntr pin signal line) may affect other lines at signal rising edge or falling edge. if such lines cross over a clock line, clock waveforms may be deformed, which causes a microcomputer failure or a program runaway. fig. 3.4.9 wiring of reset pin (3) oscillator protection using v ss pattern as for a two-sided printed circuit board, print a v ss pattern on the underside (soldering side) of the position (on the component side) where an oscillator is mounted. connect the v ss pattern to the microcomputer v ss pin with the shortest possible wiring. besides, separate this v ss pattern from other v ss patterns. fig. 3.4.10 v ss pattern on the underside of an oscillator 3.4 countermeasures against noise x in x out v ss cntr do not cross n.g. x in x out v ss an example of v ss patterns on the underside of a printed circuit board oscillator wiring pattern example separate the v ss line for oscillation from other v ss lines
3850/3851 group users manual 3-37 appendix fig. 3.4.11 setup for i/o ports 3.4.5 setup for i/o ports setup i/o ports using hardware and software as follows: ? connect a resistor of 100 w or more to an i/o port in series. ? as for an input port, read data several times by a program for checking whether input levels are equal or not. ? as for an output port, since the output data may reverse because of noise, rewrite data to its port latch at fixed periods. ? rewrite data to direction registers at fixed periods. note: when a direction register is set for input port again at fixed periods, a several-nanosecond short pulse may be output from this port. if this is undesirable, connect a capacitor to this port to remove the noise pulse. 3.4 countermeasures against noise direction register port latch data bus i/o port pins noise noise n.g. o.k.
3-38 appendix 3850/3851 group users manual 3.4.6 providing of watchdog timer function by software if a microcomputer runs away because of noise or others, it can be detected by a software watchdog timer and the microcomputer can be reset to normal operation. this is equal to or more effective than program runaway detection by a hardware watchdog timer. the following shows an example of a watchdog timer provided by software. in the following example, to reset a microcomputer to normal operation, the main routine detects errors of the interrupt processing routine and the interrupt processing routine detects errors of the main routine. this example assumes that interrupt processing is repeated multiple times in a single main routine processing. ? assigns a single byte of ram to a software watchdog timer (swdt) and writes the initial value n in the swdt once at each execution of the main routine. the initial value n should satisfy the following condition: n+1 3 ( counts of interrupt processing executed in each main routine) as the main routine execution cycle may change because of an interrupt processing or others, the initial value n should have a margin. ? watches the operation of the interrupt processing routine by comparing the swdt contents with counts of interrupt processing after the initial value n has been set. ? detects that the interrupt processing routine has failed and determines to branch to the program initialization routine for recovery processing in the following case: if the swdt contents do not change after interrupt processing. ? decrements the swdt contents by 1 at each interrupt processing. ? determines that the main routine operates normally when the swdt contents are reset to the initial value n at almost fixed cycles (at the fixed interrupt processing count). ? detects that the main routine has failed and determines to branch to the program initialization routine for recovery processing in the following case: if the swdt contents are not initialized to the initial value n but continued to decrement and if they reach 0 or less. fig. 3.4.12 watchdog timer by software 3.4 countermeasures against noise main routine (swdt) ? n cli main processing (swdt) interrupt processing routine errors n interrupt processing routine (swdt) ? (swdt)? interrupt processing (swdt) main routine errors > 0 0 rti return =n? 0? 1 n
3850/3851 group users manual 3-39 appendix 3.5 list of registers 3.5 list of registers fig. 3.5.1 structure of port pi (i=0, 1, 2, 3, 4) port pi b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name port pi 0 port pi 1 port pi 2 port pi 3 port pi 4 port pi 5 port pi 6 port pi 7 in output mode write read l port latch in input mode write : port latch read : value of pins l port pi (pi) (i = 0, 1, 2, 3, 4) [address : 00 16 , 02 16 , 04 16 , 06 16, 08 16 ] ? ? ? ? ? ? ? ? fig. 3.5.2 structure of port pi direction register(i=0, 1, 2, 3, 4) port pi direction register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name port pi direction register 0 0 0 0 0 0 0 0 port pi direction register (pid) (i = 0, 1, 2, 3, 4) [address : 01 16 , 03 16 , 05 16 , 07 16, 09 16 ] 0 : port pi 0 input mode 1 : port pi 0 output mode 0 : port pi 1 input mode 1 : port pi 1 output mode 0 : port pi 2 input mode 1 : port pi 2 output mode 0 : port pi 3 input mode 1 : port pi 3 output mode 0 : port pi 4 input mode 1 : port pi 4 output mode 0 : port pi 5 input mode 1 : port pi 5 output mode 0 : port pi 6 input mode 1 : port pi 6 output mode 0 : port pi 7 input mode 1 : port pi 7 output mode 5 5 5 5 5 5 5 5
3850/3851 group users manual 3-40 appendix 3.5 list of registers fig. 3.5.3 structure of transmit/receive buffer register fig. 3.5.4 structure of serial i/o status register transmit/receive buffer register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name ? ? ? ? ? ? ? ? transmit/receive buffer register (tb/rb) [address : 18 16 ] the transmission data is written to or the receive data is read out from this buffer register. ? at writing: a data is written to the transmit buffer register. ? at reading: the contents of the receive buffer register are read out. note: the contents of transmit buffer register cannot be read out. the data cannot be written to the receive buffer register. serial i/o status register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 1 serial i/o status register (siosts) [address : 19 16 ] nothing is allocated for this bit. this is a write disabled bit. when this bit is read out, the value is 1. 5 5 5 5 5 5 5 5 transmit buffer empty flag (tbe) 0 : (oe) (pe) (fe) = 0 1 : (oe) (pe) (fe) = 1 overrun error flag (oe) 0 : buffer full 1 : buffer empty receive buffer full flag (rbf) transmit shift register shift completion flag (tsc) parity error flag (pe) framing error flag (fe) summing error flag (se) 0 : buffer empty 1 : buffer full 0 : transmit shift in progress 1 : transmit shift completed 0 : no error 1 : overrun error 0 : no error 1 : parity error 0 : no error 1 : framing error
3850/3851 group users manual 3-41 appendix 3.5 list of registers fig. 3.5.5 structure of serial i/o control register fig. 3.5.6 structure of uart control register serial i/o control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 serial i/o control register (siocon) [address : 1a 16 ] 0 : f(x in ) 1 : f(x in )/4 brg count source selection bit (css) 0 0 : transmit disabled 1 : transmit enabled 0 : receive disabled 1 : receive enabled transmit interrupt source selection bit (tic) transmit enable bit (te) receive enable bit (re) serial i/o enable bit (sioe) s rdy output enable bit (srdy) 0 : p2 7 pin operates as ordinary i/o pin 1 : p2 7 pin operates as s rdy output pin 0 : interrupt when transmit buffer has emptied 1 : interrupt when transmit shift operation is completed serial i/o synchronous clock selection bit (scs ) ? in clock synchronous serial i/o 0 : brg output devided by 4 1 : external clock input ? in uart 0 : brg output devided by 16 1 : external clock input devided by 16 serial i/o mode selection bit (siom) 0 : clock asynchronous(uart) serial i/o 1 : clock synchronous serial i/o 0 : serial i/o disabled (pins p2 4 to p2 7 operate as ordinary i/o pins) 1 : serial i/o enabled (pins p2 4 to p2 7 operate as serial i/o pins) b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 1 uart control register (uartcon) [address : 1b 16 ] nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 1. 5 5 5 uart control register character length selection bit (chas) parity enable bit (pare) stop bit length selection bit (stps) parity selection bit (pars) in output mode 0 : cmos output 1 : n-channel open-drain output 0 : 8 bits 1 : 7 bits 0 : parity checking disabled 1 : parity checking enabled 0 : 1 stop bit 1 : 2 stop bits 0 : even parity 1 : odd parity p2 5 /txd p-channel output disable bit (poff) 1 1 0
3850/3851 group users manual 3-42 appendix 3.5 list of registers fig. 3.5.7 structure of baud rate generator fig. 3.5.8 structure of pwm control register baud rate generator b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 ? ? ? ? ? ? ? ? baud rate generator (brg) [address : 1c 16 ] set a count value of baud rate generator. pwm control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 pwm control register(pwmcon) [address : 1d 16 ] pwm function enable bit 0: pwm disabled 1: pwm enabled count source selection bit 0: f(x in ) 1: f(x in )/2 nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. 5 5 5 5 5 5
3850/3851 group users manual 3-43 appendix 3.5 list of registers fig. 3.5.9 structure of pwm prescaler fig. 3.5.10 structure of pwm register pwm prescaler b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name ? ? ? ? ? ? ? ? pwm prescaler (prepwm) [address : 1e 16 ] ? set a pwm period. ? the values set in this register is written to both the pwm prescaler pre-latch and the pwm prescaler latch at the same time. ? when data is written during pwm outputting, the pulses corresponding to the changed contents are output starting at the next cycle. ? when this register is read out, the contents of the pwm prescaler latch is read out. pwm register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name ? ? ? ? ? ? ? ? pwm register (pwm) [address : 1f 16 ] ? set a h level output period of pwm. ? the values set in this register is written to both the pwm register pre-latch and the pwm register latch at the same time. ? when data is written during pwm outputting , the pulses corresponding to the changed contents are output starting at the next cycle. ? when this register is read out, the contents of the pwm register latch is read out.
3850/3851 group users manual 3-44 appendix 3.5 list of registers fig. 3.5.11 structure of prescaler 12, prescaler x, prescaler y fig. 3.5.12 structure of timer 1 prescaler 12, prescaler x, prescaler y b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 1 1 1 1 1 1 1 1 prescaler 12 (pre12) [address : 20 16 ] prescaler x (prex) [address : 24 16 ] prescaler y (prey) [address : 26 16 ] ?set a count value of each prescaler. ?the value set in this register is written to both each prescaler and the corresponding prescaler latch at the same time. ?when this register is read out, the count value of the corres- ponding prescaler is read out. timer 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 1 0 0 0 0 0 0 0 timer 1 (t1) [address : 21 16 ] ?set a count value of timer 1. ?the value set in this register is written to both timer 1 and timer 1 latch at the same time. ?when this register is read out, the timer 1s count value is read out.
3850/3851 group users manual 3-45 appendix 3.5 list of registers fig. 3.5.13 structure of timer 2, timer x, timer y fig. 3.5.14 structure of timer count source selection register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name timer count source selection register (tcss) [address : 28 16 ] timer count source selection register timer x count source selection bit timer y count source selection bit 0 : f(x in )/16 (f(x cin )/16 at low-speed mode) 1 : f(x in )/2 (f(x cin )/2 at low-speed mode) 0 : f(x in )/16 (f(x cin )/16 at low-speed mode) 1 : f(x in )/2 (f(x cin )/2 at low-speed mode) timer 12 count source selection bit 0 : f(x in )/16 (f(x cin )/16 at low-speed mode) 1 : f(x cin ) 0 0 0 0 0 0 0 0 5 5 5 5 5 nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. timer 2, timer x, timer y b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 1 1 1 1 1 1 1 1 timer 2 (t2) [address : 22 16 ] timer x (tx) [address : 25 16 ] timer y (ty) [address : 27 16 ] ?set a count value of each timer. ?the value set in this register is written to both each timer and each timer latch at the same time. ?when this register is read out, each timers count value is read out.
3850/3851 group users manual 3-46 appendix 3.5 list of registers fig. 3.5.15 structure of timer xy mode register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 2 3 4 5 6 7 name 0 0 0 0 timer xy mode register (tm) [address : 23 ] timer xy mode register 0 0 0 0 0 : timer mode 0 1 : pulse output mode 1 0 : event counter mode 1 1 : pulse width measurement mode b1 b0 1 0 timer x operating mode bits cntr 0 active edge switch bit the function depends on the operating mode of timer x. (refer to table 3.5.1) timer x count stop bit 0 : count start 1 : count stop 16 timer y operating mode bits 0 0 : timer mode 0 1 : pulse output mode 1 0 : event counter mode 1 1 : pulse width measurement mode b5 b4 the function depends on the operating mode of timer y. (refer to table 3.5.1) 0 : count start 1 : count stop cntr 1 active edge switch bit timer y count stop bit timer x /timer y operation modes timer mode pulse output mode event counter mode pulse width measurement mode cntr 0 / cntr 1 active edge switch bit (bits 2, 6 of address 23 16 ) contents 0 cntr 0 / cntr 1 interrupt request occurrence: falling edge ; no influence to timer count 1 cntr 0 / cntr 1 interrupt request occurrence: rising edge ; no influence to timer count 0 pulse output start: beginning at h level cntr 0 / cntr 1 interrupt request occurrence: falling edge 1 pulse output start: beginning at l level cntr 0 / cntr 1 interrupt request occurrence: rising edge 0 timer x / timer y: rising edge count cntr 0 / cntr 1 interrupt request occurrence: falling edge 1 timer x / timer y: falling edge count cntr 0 / cntr 1 interrupt request occurrence: rising edge 0 timer x / timer y: h level width measurement cntr 0 / cntr 1 interrupt request occurrence: falling edge 1 timer x / timer y: l level width measurement cntr 0 / cntr 1 interrupt request occurrence: rising edge table 3.5.1 cntr 0 /cntr 1 active edge switch bit function
3850/3851 group users manual 3-47 appendix 3.5 list of registers fig. 3.5.16 structure of i 2 c data shift register fig. 3.5.17 structure of i 2 c address register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 ? ? ? ? ? ? ? ? i 2 c data shift register i 2 c data shift register (s0) [address : 2b 16 ] this register is an 8-bit shift register to store receive data or write transmit data. note: secure 8 machine cycles from clearing mst bit to 0 (slave mode) until writing data to i 2 c data shift register. if executing the read-modify-write instruction(seb, clb etc.) for this register during transfer, data may become a value not intended. b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 i 2 c address register (s0d) [address : 2c ] read / write bit (rwb) 0 : write bit 1 : read bit 0 0 0 note: if the read-modify-write instruction(seb, clb, etc.) is executed for this register at detectiong the stop condition, data may become a value not to intend. i 2 c address register 16 slave address (sad0, sad1, sad2, sad3, sad4, sad5, sad6) these bits are compared with the address data transmitted from the master.
3850/3851 group users manual 3-48 appendix 3.5 list of registers fig. 3.5.18 structure of i 2 c status register fig. 3.5.19 structure of i 2 c control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 1 0 0 i 2 c status register (s1) [address : 2d 16 ] i 2 c status register 0 ? 0 : bus free 1 : bus busy last receive bit (lrb) bus busy flag (bb) arbitration lost detecting flag (al) 0 : not detected 1 : detected ( note1 ) communication mode specification bits (trx, mst) 00 : slave receive mode 01 : slave transmit mode 10 : master receive mode 11 : master transmit mode 0 0 0 : last bit = 0 1 : last bit = 1 ( note1 ) general call detecting flag (ad0) 0 : no general call detected 1 : general call detected( note1, 2 ) slave address comparison flag (aas) 0 : address disagreement 1 : address agreement ( note1, 2 ) 5 5 5 5 scl pin low hold bit (pin) 0 : scl pin low hold 1 : scl pin low release ( note3 ) notes 1: these bits and flags can be read out, but cannot be written. 2: these bits can be detected when data format select bit (als) of i c control register is 0 . 3: 1 can be written to this bit, but 0 cannot be written by program. 4: do not execute the read-modify-write instruction (seb, clb) for this refgister, because all bits of this register are changed by hardware. 2 i 2 c control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 i 2 c control register (s1d) [address : 2e 16 ] bit counter (number of transmit/receive bits) (bc0, bc1, bc2) 0 0 0 : 8 0 0 1 : 7 0 1 0 : 6 0 1 1 : 5 1 0 0 : 4 1 0 1 : 3 1 1 0 : 2 1 1 1 : 1 b2 b1 b0 i 2 c-bus interface enable bit (es0) 0 : disabled 1 : enabled data format selection bit (als) 0 : addressing format 1 : free data format addressing format selection bit (10 bit sad) 0 : 7-bit addressing format 1 : 10-bit addressing format sda/scl pin selection bit (tsel) i 2 c-bus interface pin input level selection bit (tiss) 0 : connect to ports p2 2 , p2 3 1 : connect to ports p2 4 , p2 5 ( note 1 ) 0 : cmos input 1 : smbus input notes 1: when using p2 4 and p2 5 as i 2 c-bus interface, they are automatically switched from cmos output to p-channel output disabled. 2: when the read-modify-write instruction is executed for this register at detectiong the start condition or at completing the byte transfer, data may become a value not intended.
3850/3851 group users manual 3-49 appendix 3.5 list of registers fig. 3.5.20 structure of i 2 c clock control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 2 3 4 5 6 7 name i 2 c clock control register (s2) [address : 2f 16 ] i 2 c clock control register 0 0 0 1 scl frequency control bits (ccr0, ccr1, ccr2, ccr3, ccr4) 0 : standard clock mode 1 : high-speed clock mode scl mode specification bit (fast mode) ack bit (ack bit) ack clock bit (ack) 0 : ack is returned 1 : ack is not returned 0 : no ack clock 1 : ack clock refer to table 3.5.2 0 table 3.5.2 set value of i 2 c clock control register and scl frequency scl frequency (at f = 4 mhz, unit : khz) (note 1) setting value of ccr4Cccr0 standard clck mode setting disabled setting disabled setting disabled high-speed clock mode ccr4 0 0 0 0 0 0 0 1 1 1 ccr3 0 0 0 0 0 0 0 1 1 1 ccr2 0 0 0 0 1 1 1 1 1 1 ccr1 0 0 1 1 0 0 1 0 1 1 ccr0 0 1 0 1 0 1 0 1 0 1 setting disabled setting disabled setting disabled 34.5 33.3 32.3 100 83.3 333 250 400 (note 3) 166 C (note 2) C (note 2) 500/ccr value (note 3) 1000/ccr value (note 3) 17.2 16.6 16.1 notes 1: duty of s cl clock output is 50 %. the duty becomes 35 to 45 % only when the high-speed clock mode is selected and ccr value = 5 (400 khz, at f = 4 mhz). h duration of the clock fluctuates from C4 to +2 machine cycles in the standard clock mode, and fluctuates from C2 to +2 machine cycles in the high-speed clock mode. in the case of negative fluctuation, the frequency does not increase because l duration is extended instead of h duration reduction. these are value when s cl clock synchronization by the synchronous function is not performed. ccr value is the decimal notation value of the s cl frequency control bits ccr4 to ccr0. 2: each value of s cl frequency exceeds the limit at f = 4 mhz or more. when using these setting value, use f of 4 mhz or less. 3: the data formula of s cl frequency is described below: f /(8 5 ccr value) standard clock mode f /(4 5 ccr value) high-speed clock mode (ccr value 1 5) f /(2 5 ccr value) high-speed clock mode (ccr value = 5) do not set 0 to 2 as ccr value regardless of f frequency. set 100 khz (max.) in the standard clock mode and 400 khz (max.) in the high-speed clock mode to the s cl frequency by setting the s cl frequency control bits ccr4 to ccr0.
3850/3851 group users manual 3-50 appendix 3.5 list of registers b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 2 3 4 5 6 7 name 0 i 2 c start/stop condition control register (s2d) [address : 30 16 ] i 2 c start/stop condition control register 0 ? 1 start/stop condition set bit (ssc0, ssc1, ssc2, ssc3, ssc4) ( note ) 0 : falling edge active 1 : rising edge active s cl /s da interrupt pin polarity selection bit(sip) s cl /s da interrupt pin select on bit (sis) s cl release time = f ( m s) 5 (ssc+1) set up time = f ( m s) 5 (ssc+1)/2 hold time = f ( m s) 5 (ssc+1)/2 0 : s da valid 1 : s cl valid fix this bit to 0. 0 note : fix ssc0 bit to 0. fig. 3.5.21 structure of i 2 c start/stop condition control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 1 0 0 a-d control register (adcon) [address : 34 16 ] nothing is allocated for this bit. this is a write disabled bit. when this bit is read out, the value is 0. 5 a-d control register 0 0 0 0 : p3 0 /an 0 0 0 1 : p3 1 /an 1 0 1 0 : p3 2 /an 2 0 1 1 : p3 3 /an 3 1 0 0 : p3 4 /an 4 1 0 1 : p3 5 /an 5 1 1 0 : p3 6 /an 6 1 1 1 : p3 7 /an 7 analog input pin selection bits b2 b1 b0 0 0 ad conversion completion bit 0 : conversion in progress 1 : conversion completed nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. 0 5 5 5 fig. 3.5.22 structure of a-d control register
3850/3851 group users manual 3-51 appendix 3.5 list of registers fig. 3.5.23 structure of a-d conversion register(low-order) a-d conversion register (low-order) b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 ? ? ? ? ? ? ? ? a-d conversion register (low-order) (adl) [address : 35 ] the read-only register in which the a-d conversions results are stored. 5 5 5 5 5 5 5 5 < 8-bit read> b7 b8 b7 b6 b5 b4 b3 b0 b2 b9 < 10-bit read> b7 b6 b5 b4 b3 b2 b1 b0 b0 b7 16 a-d conversion register (high-order) b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name ? ? ? ? ? ? ? ? the read-only register in which the a-d conversions results are stored. 5 5 5 5 5 5 5 5 < 10-bit read> b7 b9 b0 b8 nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. a-d conversion register (high-order) (adh) [address : 36 ] 16 fig. 3.5.24 structure of a-d conversion register (high-order)
3850/3851 group users manual 3-52 appendix 3.5 list of registers fig. 3.5.25 structure of misrg b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. 5 misrg oscillation stabilization time set bit after release of the stp instruction 0 0 : set automatically (note 1) 1 : not set automatically 0 0 0 5 5 5 misrg [address : 38 ] 16 0 : not set automatically 1 : automatic switching enable (notes 2, 3) middle-speed mode automatic switch set bit middle-speed mode automatic switch wait time set bit 0 : 4.5 to 5.5 machine cycles 1 : 6.5 to 7.5 machine cycles middle-speed mode automatic switch start bit (depending on program) notes 1: automatically set 01 16 to timer 1, and ff 16 to priscaler 12. 2: during operation in low-speed mode, it is possible automatically to switch to middle-speed mode owing to s cl /s da interrupt. 3: when automatic switch to middle-speed mode from low-speed mode occurs, the values of cpu mode register (3b 16 ) change. 0 : invalid 1 : automatic switch start (note 3) watchdog timer control register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 1 1 1 1 1 1 0 0 watchdog timer control register (wdtcon) [address : 39 16 ] watchdog timer h stp instruction disable bit ( note ) 0 : stp instruction enabled 1 : stp instruction disabled watchdog timer h count source selection bit 0 : watchdog timer l underflow 1 : f(x in )/16 or f(x cin )/16 5 5 5 5 5 5 ?the watchdog timer starts to count down by writing an optional value into this register after resetting. ?this bits are cleared to 000000 2 by writing an optional value into this register. note: when this bit is set to 1, it cannot be rewriten to 0 by program. fig. 3.5.26 structure of watchdog timer control register
3850/3851 group users manual 3-53 appendix 3.5 list of registers fig. 3.5.27 structure of interrupt edge selection register interrupt edge selection register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt edge selection register (intedge) [address : 3a 16 ] nothing is allocated for these bits. these are write disabled bits. when these bits are read out, the values are 0. int 0 interrupt edge selection bit int 1 interrupt edge selection bit 0 : falling edge active 1 : rising edge active 0 : falling edge active 1 : rising edge active int 2 interrupt edge selection bit int 3 interrupt edge selection bit 0 : falling edge active 1 : rising edge active 0 : falling edge active 1 : rising edge active 5 5 5 5 this is the reserved bit. do not write 1 to this bit. fig. 3.5.28 structure of cpu mode register b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 2 3 4 5 6 7 name 0 1 0 0 cpu mode register (cpum) [address : 3b 16 ] cpu mode register 1 0 0 0 0 : single-chip mode 0 1 : not available 1 0 : not available 1 1 : not available b1 b0 1 processor mode bits 0 : operating 1 : stopped 0 : 0 page 1 : 1 page stack page selection bit main clock (x in -x out ) stop bit main clock division ratio selection bits 0 0 : f = f(x in )/2 (high-speedmode) 0 1 : f = f(x in )/8 (middle-speed mode) 1 0 : f = f(x cin )/2 (low-speed mode) 1 1 : f = not available b7 b6 port xc switch bit 0 : i/o port function 1 : xcin-xcout operating function fix this bit to 1. note: an initial value of bit 1 depends on the cnv pin level. 0 (note) ss
3850/3851 group users manual 3-54 appendix 3.5 list of registers interrupt request register 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt request register 1 (ireq1) [address : 3c 16 ] int 0 interrupt request bit scl/sda interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued i 2 c interrupt request bit timer x interrupt request bit ] : these bits can be cleared to 0 by program, but cannot be set to 1. 0 : no interrupt request issued 1 : interrupt request issued int 1 interrupt request bit int 2 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued int 3 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued ] ] ] ] ] ] ] timer y interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued ] fig. 3.5.29 structure of interrupt request register 1 interrupt request register 2 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt request register 2 (ireq2) [address : 3d 16 ] nothing is allocated for this bit. this is a write disabled bit. when this bit is read out, the value is 0. 5 timer 1 interrupt request bit timer 2 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued cntr 1 interrupt request bit ad converter interrupt request bit ] : these bits can be cleared to 0 by program, but cannot be set to 1. 0 : no interrupt request issued 1 : interrupt request issued serial i/o receive interrupt request bit serial i/o transmit interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued cntr 0 interrupt request bit 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued ] ] ] ] ] ] ] fig. 3.5.30 structure of interrupt request register 2
3850/3851 group users manual 3-55 appendix 3.5 list of registers interrupt control register 1 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt control register 1 (icon1) [address : 3e 16 ] int 0 interrupt enable bit scl/sda interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled i 2 c interrupt enable bit timer x interrupt enable bit int 1 interrupt enable bit int 2 interrupt enable bit int 3 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled timer y interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled fig. 3.5.31 structure of interrupt control register 1 interrupt control register 2 b7 b6 b5 b4 b3 b2 b1 b0 b function at reset rw 0 1 2 3 4 5 6 7 name 0 0 0 0 0 0 0 0 interrupt control register 2 (icon2) [address : 3f 16 ] fix this bit to 0. timer 1 interrupt enable bit timer 2 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled cntr 1 interrupt enable bit ad converter interrupt enable bit serial i/o receive interrupt enable bit serial i/o transmit interrupt enable bit cntr 0 interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 fig. 3.5.32 structure of interrupt control register 2
3850/3851 group users manual appendix 3.6 mask rom confirmation form 3-56 gzz-sh53-11b<86a0> receipt 740 family mask rom confirmation form single-chip microcomputer m38503m2-xxxsp/fp mitsubishi electric mask rom number date: section head signature supervisor signature company name note : please fill in all items marked h . customer h issuance signature date issued submitted by tel () date: supervisor h 1. confirmation specify the name of the product being ordered and the type of eproms submitted. three eproms are required for each pattern. if at least two of the three sets of eproms submitted contain identical data, we will produce masks based on this data. we shall assume the responsibility for errors only if the mask rom data on the products we produce differs from this data. thus, extreme care must be taken to verify the data in the submitted eproms. checksum code for entire eprom (hexadecimal notation) in the address space of the microcomputer, the internal rom area is from address e080 16 to fffd 16 . the reset vector is stored in addresses fffc 16 and fffd 16 . (1) set the data in the unused area (the shaded area of the diagram) to ff 16 . (2) the ascii codes of the product name m38503m2C must be entered in addresses 0000 16 to 0008 16 . and set the data ff 16 in addresses 0009 16 to 000f 16 . the ascii codes and addresses are listed to the right in hexadecimal notation. address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 m = 4d 16 3 = 33 16 8 = 38 16 5 = 35 16 0 = 30 16 3 = 33 16 m = 4d 16 2 = 32 16 address 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 C = 2d 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 (1/2) eprom type (indicate the type used) 27256 eprom address 0000 16 000f 16 0010 16 607f 16 6080 16 7ffd 16 7ffe 16 7fff 16 product name ascii code : m38503m2- data rom (8k-130) bytes 27512 eprom address 0000 16 000f 16 0010 16 e07f 16 e080 16 fffd 16 fffe 16 ffff 16 product name ascii code : m38503m2- data rom (8k-130) bytes microcomputer name: m38503m2-xxxsp m38503m2-xxxfp 3.6 mask rom ordering method
3850/3851 group users manual appendix 3-57 3.6 mask rom confirmation form 27256 *= $8000 .byte m38503m2C 740 family mask rom confirmation form single-chip microcomputer m38503m2-xxxsp/fp mitsubishi electric gzz-sh53-11b<86a0> mask rom number we recommend the use of the following pseudo-command to set the start address of the assembler source program be- cause ascii codes of the product name are written to addresses 0000 16 to 0008 16 of eprom. eprom type the pseudo-command note : if the name of the product written to the eproms does not match the name of the mask confirmation form, the rom will not be processed. h 2. mark specification mark specification must be submitted using the correct form for the package being ordered. fill out the appropriate mark specification form (42p4b for m38503m2-xxxsp, 42p2r-a for m38503m2-xxxfp) and attach it to the mask rom confirmation form. h 3. usage conditions please answer the following questions about usage for use in our product inspection : (1) how will you use the x in -x out oscillator? at what frequency? f(x in ) = (2) which function will you use the pins p2 1 /x cin and p2 0 /x cout as p2 1 and p2 0 , or x cin and x cout ? ceramic resonator external clock input ports p2 1 and p2 0 function quartz crystal other ( ) x cin and x cout function (external resonator) mhz h 4. comments 27512 *= $0000 .byte m38503m2C (2/2)
3850/3851 group users manual appendix 3.6 mask rom confirmation form 3-58 gzz-sh11-40a<6ya0> receipt 740 family mask rom confirmation form single-chip microcomputer m38503m4-xxxsp/fp mitsubishi electric mask rom number date: section head signature supervisor signature company name note : please fill in all items marked h . customer h issuance signature date issued submitted by tel () date: supervisor h 1. confirmation specify the name of the product being ordered and the type of eproms submitted. three eproms are required for each pattern. if at least two of the three sets of eproms submitted contain identical data, we will produce masks based on this data. we shall assume the responsibility for errors only if the mask rom data on the products we produce differs from this data. thus, extreme care must be taken to verify the data in the submitted eproms. checksum code for entire eprom (hexadecimal notation) in the address space of the microcomputer, the internal rom area is from address c080 16 to fffd 16 . the reset vector is stored in addresses fffc 16 and fffd 16 . (1) set the data in the unused area (the shaded area of the diagram) to ff 16 . (2) the ascii codes of the product name m38503m4C must be entered in addresses 0000 16 to 0008 16 . and set the data ff 16 in addresses 0009 16 to 000f 16 . the ascii codes and addresses are listed to the right in hexadecimal notation. address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 m = 4d 16 3 = 33 16 8 = 38 16 5 = 35 16 0 = 30 16 3 = 33 16 m = 4d 16 4 = 34 16 address 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 C = 2d 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 (1/2) eprom type (indicate the type used) 27256 eprom address 0000 16 000f 16 0010 16 407f 16 4080 16 7ffd 16 7ffe 16 7fff 16 product name ascii code : m38503m4- data rom (16k-130) bytes 27512 eprom address 0000 16 000f 16 0010 16 c07f 16 c080 16 fffd 16 fffe 16 ffff 16 product name ascii code : m38503m4- data rom (16k-130) bytes microcomputer name: m38503m4-xxxsp m38503m4-xxxfp
3850/3851 group users manual appendix 3-59 3.6 mask rom confirmation form 27256 *= $8000 .byte m38503m4C 740 family mask rom confirmation form single-chip microcomputer m38503m4-xxxsp/fp mitsubishi electric gzz-sh11-40a<6ya0> mask rom number we recommend the use of the following pseudo-command to set the start address of the assembler source program be- cause ascii codes of the product name are written to addresses 0000 16 to 0008 16 of eprom. eprom type the pseudo-command note : if the name of the product written to the eproms does not match the name of the mask confirmation form, the rom will not be processed. (2/2) h 2. mark specification mark specification must be submitted using the correct form for the package being ordered. fill out the appropriate mark specification form (42p4b for m38503m4-xxxsp, 42p2r-a for m38503m4-xxxfp) and attach it to the mask rom confirmation form. h 3. usage conditions please answer the following questions about usage for use in our product inspection : (1) how will you use the x in -x out oscillator? at what frequency? f(x in ) = (2) which function will you use the pins p2 1 /x cin and p2 0 /x cout as p2 1 and p2 0 , or x cin and x cout ? ceramic resonator external clock input ports p2 1 and p2 0 function quartz crystal other ( ) x cin and x cout function (external resonator) mhz h 4. comments 27512 *= $0000 .byte m38503m4C
3850/3851 group users manual appendix 3.6 mask rom confirmation form 3-60 gzz-sh54-31b<89a0> receipt 740 family mask rom confirmation form single-chip microcomputer m38504m6-xxxsp/fp mitsubishi electric mask rom number date: section head signature supervisor signature company name note : please fill in all items marked h . customer h issuance signature date issued submitted by tel () date: supervisor h 1. confirmation specify the name of the product being ordered and the type of eproms submitted. three eproms are required for each pattern. if at least two of the three sets of eproms submitted contain identical data, we will produce masks based on this data. we shall assume the responsibility for errors only if the mask rom data on the products we produce differs from this data. thus, extreme care must be taken to verify the data in the submitted eproms. checksum code for entire eprom (hexadecimal notation) in the address space of the microcomputer, the internal rom area is from address a080 16 to fffd 16 . the reset vector is stored in addresses fffc 16 and fffd 16 . (1) set the data in the unused area (the shaded area of the diagram) to ff 16 . (2) the ascii codes of the product name m38504m6C must be entered in addresses 0000 16 to 0008 16 . and set the data ff 16 in addresses 0009 16 to 000f 16 . the ascii codes and addresses are listed to the right in hexadecimal notation. address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 m = 4d 16 3 = 33 16 8 = 38 16 5 = 35 16 0 = 30 16 4 = 34 16 m = 4d 16 6 = 36 16 address 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 C = 2d 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 (1/2) eprom type (indicate the type used) microcomputer name : m38504m6-xxxsp m38504m6-xxxfp 27256 eprom address 0000 16 000f 16 0010 16 207f 16 2080 16 7ffd 16 7ffe 16 7fff 16 product name ascii code : m38504m6- data rom (24k-130) bytes 27512 eprom address 0000 16 000f 16 0010 16 a07f 16 a080 16 fffd 16 fffe 16 ffff 16 product name ascii code : m38504m6- data rom (24k-130) bytes
3850/3851 group users manual appendix 3-61 3.6 mask rom confirmation form 27256 *= $8000 .byte m38504m6C 740 family mask rom confirmation form single-chip microcomputer m38504m6-xxxsp/fp mitsubishi electric gzz-sh54-31b<89a0> mask rom number we recommend the use of the following pseudo-command to set the start address of the assembler source program. eprom type the pseudo-command note : if the name of the product written to the eproms does not match the name of the mask confirmation form, the rom will not be processed. (2/2) h 2. mark specification mark specification must be submitted using the correct form for the package being ordered. fill out the appropriate mark specification form (42p4b for m38504m6-xxxsp , 42p2r for m38504m6-xxxfp) and attach it to the mask rom confirmation form. h 3. usage conditions please answer the following questions about usage for use in our product inspection : (1) how will you use the x in -x out oscillator? at what frequency? f(x in ) = (2) which function will you use the pins p2 1 /x cin and p2 0 /x cout as p2 1 and p2 0 , or x cin and x cout ? ceramic resonator external clock input ports p2 1 and p2 0 function quartz crystal other ( ) x cin and x cout function (external resonator) mhz h 4. comments 27512 *= $0000 .byte m38504m6C
3850/3851 group users manual appendix 3.6 mask rom confirmation form 3-62 gzz-sh52-61b<83a0> receipt 740 family mask rom confirmation form single-chip microcomputer m38513m4-xxxsp/fp mitsubishi electric mask rom number date: section head signature supervisor signature company name note : please fill in all items marked h . customer h issuance signature date issued submitted by tel () date: supervisor h 1. confirmation specify the name of the product being ordered and the type of eproms submitted. three eproms are required for each pattern. if at least two of the three sets of eproms submitted contain identical data, we will produce masks based on this data. we shall assume the responsibility for errors only if the mask rom data on the products we produce differs from this data. thus, extreme care must be taken to verify the data in the submitted eproms. checksum code for entire eprom (hexadecimal notation) in the address space of the microcomputer, the internal rom area is from address c080 16 to fffd 16 . the reset vector is stored in addresses fffc 16 and fffd 16 . (1) set the data in the unused area (the shaded area of the diagram) to ff 16 . (2) the ascii codes of the product name m38513m4C must be entered in addresses 0000 16 to 0008 16 . and set the data ff 16 in addresses 0009 16 to 000f 16 . the ascii codes and addresses are listed to the right in hexadecimal notation. address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 m = 4d 16 3 = 33 16 8 = 38 16 5 = 35 16 1 = 31 16 3 = 33 16 m = 4d 16 4 = 34 16 address 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 C = 2d 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 (1/2) eprom type (indicate the type used) 27256 eprom address 0000 16 000f 16 0010 16 407f 16 4080 16 7ffd 16 7ffe 16 7fff 16 product name ascii code : m38513m4- data rom (16k-130) bytes 27512 eprom address 0000 16 000f 16 0010 16 c07f 16 c080 16 fffd 16 fffe 16 ffff 16 product name ascii code : m38513m4- data rom (16k-130) bytes microcomputer name: m38513m4-xxxsp m38513m4-xxxfp
3850/3851 group users manual appendix 3-63 3.6 mask rom confirmation form 27256 *= $8000 .byte m38513m4C 740 family mask rom confirmation form single-chip microcomputer m38513m4-xxxsp/fp mitsubishi electric gzz-sh52-61b<83a0> mask rom number we recommend the use of the following pseudo-command to set the start address of the assembler source program be- cause ascii codes of the product name are written to addresses 0000 16 to 0008 16 of eprom. eprom type the pseudo-command note : if the name of the product written to the eproms does not match the name of the mask confirmation form, the rom will not be processed. (2/2) h 2. mark specification mark specification must be submitted using the correct form for the package being ordered. fill out the appropriate mark specification form (42p4b for m38513m4-xxxsp, 42p2r for m38513m4-xxxfp) and attach it to the mask rom confirmation form. h 3. usage conditions please answer the following questions about usage for use in our product inspection : (1) how will you use the x in -x out oscillator? at what frequency? f(x in ) = (2) which function will you use the pins p2 1 /x cin and p2 0 /x cout as p2 1 and p2 0 , or x cin and x cout ? ceramic resonator external clock input ports p2 1 and p2 0 function quartz crystal other ( ) x cin and x cout function (external resonator) mhz (3) will you use the i 2 c-bus function or the sm-bus function ? h 4. comments i 2 c-bus function used not used sm-bus function used 27512 *= $0000 .byte m38513m4C
3850/3851 group users manual appendix 3.6 mask rom confirmation form 3-64 gzz-sh54-32b<89a0> receipt 740 family mask rom confirmation form single-chip microcomputer m38514m6-xxxsp/fp mitsubishi electric mask rom number date: section head signature supervisor signature company name note : please fill in all items marked h . customer h issuance signature date issued submitted by tel () date: supervisor h 1. confirmation specify the name of the product being ordered and the type of eproms submitted. three eproms are required for each pattern. if at least two of the three sets of eproms submitted contain identical data, we will produce masks based on this data. we shall assume the responsibility for errors only if the mask rom data on the products we produce differs from this data. thus, extreme care must be taken to verify the data in the submitted eproms. checksum code for entire eprom (hexadecimal notation) in the address space of the microcomputer, the internal rom area is from address a080 16 to fffd 16 . the reset vector is stored in addresses fffc 16 and fffd 16 . (1) set the data in the unused area (the shaded area of the diagram) to ff 16 . (2) the ascii codes of the product name m38514m6C must be entered in addresses 0000 16 to 0008 16 . and set the data ff 16 in addresses 0009 16 to 000f 16 . the ascii codes and addresses are listed to the right in hexadecimal notation. address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 m = 4d 16 3 = 33 16 8 = 38 16 5 = 35 16 1 = 31 16 4 = 34 16 m = 4d 16 6 = 36 16 address 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 C = 2d 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 (1/2) eprom type (indicate the type used) microcomputer name : m38514m6-xxxsp m38514m6-xxxfp 27256 eprom address 0000 16 000f 16 0010 16 207f 16 2080 16 7ffd 16 7ffe 16 7fff 16 product name ascii code : m38514m6- data rom (24k-130) bytes 27512 eprom address 0000 16 000f 16 0010 16 a07f 16 a080 16 fffd 16 fffe 16 ffff 16 product name ascii code : m38514m6- data rom (24k-130) bytes
3850/3851 group users manual appendix 3-65 3.6 mask rom confirmation form 27256 *= $8000 .byte m38514m6C 740 family mask rom confirmation form single-chip microcomputer m38514m6-xxxsp/fp mitsubishi electric gzz-sh54-32b<89a0> mask rom number we recommend the use of the following pseudo-command to set the start address of the assembler source program. eprom type the pseudo-command note : if the name of the product written to the eproms does not match the name of the mask confirmation form, the rom will not be processed. (2/2) h 2. mark specification mark specification must be submitted using the correct form for the package being ordered. fill out the appropriate mark specification form (42p4b for m38514m6-xxxsp , 42p2r for m38514m6-xxxfp) and attach it to the mask rom confirmation form. h 3. usage conditions please answer the following questions about usage for use in our product inspection : (1) how will you use the x in -x out oscillator? at what frequency? f(x in ) = (2) which function will you use the pins p2 1 /x cin and p2 0 /x cout as p2 1 and p2 0 , or x cin and x cout ? ceramic resonator external clock input ports p2 1 and p2 0 function quartz crystal other ( ) x cin and x cout function (external resonator) mhz (3) will you use the i 2 c-bus function or the sm-bus function ? h 4. comments i 2 c-bus function used not used sm-bus function used 27512 *= $0000 .byte m38514m6C
3850/3851 group users manual appendix 3.7 rom programming confirmation form 3-66 3.7 rom programming confirmation form gzz-sh11-41a<6ya0> receipt 740 family rom programming confirmation form single-chip microcomputer m38503e4-xxxsp/fp mitsubishi electric rom number date: section head signature supervisor signature company name note : please fill in all items marked h . customer h issuance signature date issued submitted by tel () date: supervisor h 1. confirmation specify the name of the product being ordered and the type of eproms submitted. three eproms are required for each pattern. if at least two of the three sets of eproms submitted contain identical data, we will produce rom programming based on this data. we shall assume the responsibility for errors only if the programming data on the products we produce dif- fers from this data. thus, extreme care must be taken to verify the data in the submitted eproms. checksum code for entire eprom (hexadecimal notation) in the address space of the microcomputer, the internal rom area is from address c080 16 to fffd 16 . the reset vector is stored in addresses fffc 16 and fffd 16 . (1) set the data in the unused area (the shaded area of the diagram) to ff 16 . (2) the ascii codes of the product name m38503e4C must be entered in addresses 0000 16 to 0008 16 . and set the data ff 16 in addresses 0009 16 to 000f 16 . the ascii codes and addresses are listed to the right in hexadecimal notation. address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 m = 4d 16 3 = 33 16 8 = 38 16 5 = 35 16 0 = 30 16 3 = 33 16 e = 45 16 4 = 34 16 address 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 C = 2d 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 (1/2) eprom type (indicate the type used) 27256 eprom address 0000 16 000f 16 0010 16 407f 16 4080 16 7ffd 16 7ffe 16 7fff 16 product name ascii code : m38503e4- data rom (16k-130) bytes 27512 eprom address 0000 16 000f 16 0010 16 c07f 16 c080 16 fffd 16 fffe 16 ffff 16 product name ascii code : m38503e4- data rom (16k-130) bytes microcomputer name: m38503e4-xxxsp m38503e4-xxxfp
3850/3851 group users manual appendix 3-67 3.7 rom programming confirmation form 27256 *= $8000 .byte m38503e4C 740 family rom programming confirmation form single-chip microcomputer m38503e4-xxxsp/fp mitsubishi electric gzz-sh11-41a<6ya0> rom number we recommend the use of the following pseudo-command to set the start address of the assembler source program be- cause ascii codes of the product name are written to addresses 0000 16 to 0008 16 of eprom. eprom type the pseudo-command note : if the name of the product written to the eproms does not match the name of the rom programming confirmation form, the rom will not be processed. (2/2) h 2. mark specification mark specification must be submitted using the correct form for the package being ordered. fill out the appropriate mark specification form; 42p2r-a for the m38503e4-xxxfp, the shrink dip package mark specification form (only for built-in one time prom microcomputer) for the m38503e4-xxxsp; and attach it to the rom programming confirma- tion form. h 3. usage conditions please answer the following questions about usage for use in our product inspection : (1) how will you use the x in -x out oscillator? at what frequency? f(x in ) = (2) which function will you use the pins p2 1 /x cin and p2 0 /x cout as p2 1 and p2 0 , or x cin and x cout ? ceramic resonator external clock input ports p2 1 and p2 0 function quartz crystal other ( ) x cin and x cout function (external resonator) mhz h 4. comments 27512 *= $0000 .byte m38503e4C
3850/3851 group users manual appendix 3.7 rom programming confirmation form 3-68 gzz-sh53-16b<86a0> receipt 740 family rom programming confirmation form single-chip microcomputer m38504e6-xxxfp/sp mitsubishi electric rom number date: section head signature supervisor signature company name note : please fill in all items marked h . customer h issuance signature date issued submitted by tel () date: supervisor h 1. confirmation specify the name of the product being ordered and the type of eproms submitted. three eproms are required for each pattern. if at least two of the three sets of eproms submitted contain identical data, we will produce rom programming based on this data. we shall assume the responsibility for errors only if the programming data on the products we produce dif- fers from this data. thus, extreme care must be taken to verify the data in the submitted eproms. checksum code for entire eprom (hexadecimal notation) in the address space of the microcomputer, the internal rom area is from address a080 16 to fffd 16 . the reset vector is stored in addresses fffc 16 and fffd 16 . (1) set the data in the unused area (the shaded area of the diagram) to ff 16 . (2) the ascii codes of the product name m38504e6C must be entered in addresses 0000 16 to 0008 16 . and set the data ff 16 in addresses 0009 16 to 000f 16 . the ascii codes and addresses are listed to the right in hexadecimal notation. address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 m = 4d 16 3 = 33 16 8 = 38 16 5 = 35 16 0 = 30 16 4 = 34 16 e = 45 16 6 = 36 16 address 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 C = 2d 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 (1/2) eprom type (indicate the type used) 27256 eprom address 0000 16 000f 16 0010 16 207f 16 2080 16 7ffd 16 7ffe 16 7fff 16 product name ascii code : m38504e6- data rom (24k-130) bytes 27512 eprom address 0000 16 000f 16 0010 16 a07f 16 a080 16 fffd 16 fffe 16 ffff 16 product name ascii code : m38504e6- data rom (24k-130) bytes product name: m38504e6-xxxfp m38504e6-xxxsp
3850/3851 group users manual appendix 3-69 3.7 rom programming confirmation form 27256 *= $8000 .byte m38504e6C 740 family rom programming confirmation form single-chip microcomputer m38504e6-xxxfp/sp mitsubishi electric gzz-sh53-16b<86a0> rom number we recommend the use of the following pseudo-command to set the start address of the assembler source program be- cause ascii codes of the product name are written to addresses 0000 16 to 0008 16 of eprom. eprom type the pseudo-command note : if the name of the product written to the eproms does not match the name of the rom programming confirmation form, the rom will not be processed. (2/2) h 2. mark specification mark specification must be submitted using the correct form for the package being ordered. fill out the appropriate mark specification form; 42p2r for the m38504e6-xxxfp, the shrink dip package mark specification form (only for built-in one time prom microcomputer) for the m38504e6-xxxsp; and attach it to the rom programming confirma- tion form. h 3. usage conditions please answer the following questions about usage for use in our product inspection : (1) how will you use the x in -x out oscillator? at what frequency? f(x in ) = (2) which function will you use the pins p2 1 /x cin and p2 0 /x cout as p2 1 and p2 0 , or x cin and x cout ? ceramic resonator external clock input ports p2 1 and p2 0 function quartz crystal other ( ) x cin and x cout function (external resonator) mhz h 4. comments 27512 *= $0000 .byte m38504e6C
3850/3851 group users manual appendix 3.7 rom programming confirmation form 3-70 gzz-sh11-43a<6yb0> receipt 740 family rom programming confirmation form single-chip microcomputer m38513e4-xxxsp/fp mitsubishi electric rom number date: section head signature supervisor signature company name note : please fill in all items marked h . customer h issuance signature date issued submitted by tel () date: supervisor h 1. confirmation specify the name of the product being ordered and the type of eproms submitted. three eproms are required for each pattern. if at least two of the three sets of eproms submitted contain identical data, we will produce rom programming based on this data. we shall assume the responsibility for errors only if the programming data on the products we produce dif- fers from this data. thus, extreme care must be taken to verify the data in the submitted eproms. checksum code for entire eprom (hexadecimal notation) in the address space of the microcomputer, the internal rom area is from address c080 16 to fffd 16 . the reset vector is stored in addresses fffc 16 and fffd 16 . (1) set the data in the unused area (the shaded area of the diagram) to ff 16 . (2) the ascii codes of the product name m38513e4C must be entered in addresses 0000 16 to 0008 16 . and set the data ff 16 in addresses 0009 16 to 000f 16 . the ascii codes and addresses are listed to the right in hexadecimal notation. address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 m = 4d 16 3 = 33 16 8 = 38 16 5 = 35 16 1 = 31 16 3 = 33 16 e = 45 16 4 = 34 16 address 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 C = 2d 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 (1/2) eprom type (indicate the type used) 27256 eprom address 0000 16 000f 16 0010 16 407f 16 4080 16 7ffd 16 7ffe 16 7fff 16 product name ascii code : m38513e4- data rom (16k-130) bytes 27512 eprom address 0000 16 000f 16 0010 16 c07f 16 c080 16 fffd 16 fffe 16 ffff 16 product name ascii code : m38513e4- data rom (16k-130) bytes microcomputer name: m38513e4-xxxsp m38513e4-xxxfp
3850/3851 group users manual appendix 3-71 3.7 rom programming confirmation form 27256 *= $8000 .byte m38513e4C 740 family rom programming confirmation form single-chip microcomputer m38513e4-xxxsp/fp mitsubishi electric gzz-sh11-43a<6yb0> rom number we recommend the use of the following pseudo-command to set the start address of the assembler source program be- cause ascii codes of the product name are written to addresses 0000 16 to 0008 16 of eprom. eprom type the pseudo-command note : if the name of the product written to the eproms does not match the name of the rom programming confirmation form, the rom will not be processed. (2/2) h 2. mark specification mark specification must be submitted using the correct form for the package being ordered. fill out the appropriate mark specification form; 42p2r for the m38513e4-xxxfp, the shrink dip package mark specification form (only for built-in one time prom microcomputer) for the m38513e4-xxxsp; and attach it to the rom programming confirma- tion form. h 3. usage conditions please answer the following questions about usage for use in our product inspection : (1) how will you use the x in -x out oscillator? at what frequency? f(x in ) = (2) which function will you use the pins p2 1 /x cin and p2 0 /x cout as p2 1 and p2 0 , or x cin and x cout ? ceramic resonator external clock input ports p2 1 and p2 0 function quartz crystal other ( ) x cin and x cout function (external resonator) mhz (3) will you use the i 2 c-bus function or the sm-bus function ? h 4. comments i 2 c-bus function used not used sm-bus function used 27512 *= $0000 .byte m38513e4C
3850/3851 group users manual appendix 3.7 rom programming confirmation form 3-72 gzz-sh53-16b<86a0> receipt 740 family rom programming confirmation form single-chip microcomputer m38514e6-xxxfp/sp mitsubishi electric rom number date: section head signature supervisor signature company name note : please fill in all items marked h . customer h issuance signature date issued submitted by tel () date: supervisor h 1. confirmation specify the name of the product being ordered and the type of eproms submitted. three eproms are required for each pattern. if at least two of the three sets of eproms submitted contain identical data, we will produce rom programming based on this data. we shall assume the responsibility for errors only if the programming data on the products we produce dif- fers from this data. thus, extreme care must be taken to verify the data in the submitted eproms. checksum code for entire eprom (hexadecimal notation) in the address space of the microcomputer, the internal rom area is from address a080 16 to fffd 16 . the reset vector is stored in addresses fffc 16 and fffd 16 . (1) set the data in the unused area (the shaded area of the diagram) to ff 16 . (2) the ascii codes of the product name m38514e6C must be entered in addresses 0000 16 to 0008 16 . and set the data ff 16 in addresses 0009 16 to 000f 16 . the ascii codes and addresses are listed to the right in hexadecimal notation. address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 m = 4d 16 3 = 33 16 8 = 38 16 5 = 35 16 1 = 31 16 4 = 34 16 e = 45 16 6 = 36 16 address 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 C = 2d 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 ff 16 (1/2) eprom type (indicate the type used) 27256 eprom address 0000 16 000f 16 0010 16 207f 16 2080 16 7ffd 16 7ffe 16 7fff 16 product name ascii code : m38514e6- data rom (24k-130) bytes 27512 eprom address 0000 16 000f 16 0010 16 a07f 16 a080 16 fffd 16 fffe 16 ffff 16 product name ascii code : m38514e6- data rom (24k-130) bytes product name: m38514e6-xxxfp m38514e6-xxxsp
3850/3851 group users manual appendix 3-73 3.7 rom programming confirmation form 27256 *= $8000 .byte m38514e6C 740 family rom programming confirmation form single-chip microcomputer m38514e6-xxxfp/sp mitsubishi electric gzz-sh53-16b<86a0> rom number we recommend the use of the following pseudo-command to set the start address of the assembler source program be- cause ascii codes of the product name are written to addresses 0000 16 to 0008 16 of eprom. eprom type the pseudo-command note : if the name of the product written to the eproms does not match the name of the rom programming confirmation form, the rom will not be processed. (2/2) h 2. mark specification mark specification must be submitted using the correct form for the package being ordered. fill out the appropriate mark specification form; 42p2r for the m38514e6-xxxfp, the shrink dip package mark specification form (only for built-in one time prom microcomputer) for the m38514e6-xxxsp; and attach it to the rom programming confirma- tion form. h 3. usage conditions please answer the following questions about usage for use in our product inspection : (1) how will you use the x in -x out oscillator? at what frequency? f(x in ) = (2) which function will you use the pins p2 1 /x cin and p2 0 /x cout as p2 1 and p2 0 , or x cin and x cout ? ceramic resonator external clock input ports p2 1 and p2 0 function quartz crystal other ( ) x cin and x cout function (external resonator) mhz (3) will you use the i 2 c-bus function or the sm-bus function ? h 4. comments i 2 c-bus function used not used sm-bus function used 27512 *= $0000 .byte m38514e6C
3850/3851 group users manual appendix 3.8 mark specification form 3-74 3.8 mark specification form
3850/3851 group users manual appendix 3-75 3.8 mark specification form
3850/3851 group users manual appendix 3.9 package outline 3-76 3.9 package outline ssop42-p-450-0.80 weight(g) jedec code 0.63 eiaj package code lead material alloy 42/cu alloy 42p2r-a plastic 42pin 450mil ssop symbol min nom max a a 2 b c d e l l 1 y dimension in millimeters h e a 1 i 2 .35 0 .05 0 .13 0 .3 17 .2 8 .63 11 .3 0 .27 1 .0 2 .4 0 .15 0 .5 17 .4 8 .8 0 .93 11 .5 0 .765 1 .43 11 .4 2 .5 0 .2 0 .7 17 .6 8 .23 12 .7 0 .15 0 b 2 ?5 0 0 ?0 e e 1 42 22 21 1 h e e d b e y f a a 2 a 1 l 1 l c e b 2 e 1 i 2 recommended mount pad detail f sdip42-p-600-1.78 weight(g) jedec code 4.1 eiaj package code lead material alloy 42/cu alloy 42p4b plastic 42pin 600mil sdip symbol min nom max a a 2 b b 1 b 2 c e d l dimension in millimeters a 1 0.51 ?.8 0.35 0.45 0.55 0.9 1.0 1.3 0.63 0.73 1.03 0.22 0.27 0.34 36.5 36.7 36.9 12.85 13.0 13.15 1.778 15.24 3.0 0 ?5 5.5 e e 1 42 22 21 1 e c e 1 a 2 a 1 b b 1 b 2 e la seating plane d caution ! tbd 42p2r-a package outline is to be updated.
3850/3851 group users manual appendix 3-77 3.9 package outline wdip42-c-600-1.78 weight(g) jedec code eiaj package code 42s1b-a metal seal 42pin 600mil dip 0.46 0.25 3.44 15.8 3.05 symbol min nom max a a 2 b b 1 c d e l z dimension in millimeters a 1 3.05 15.24 1.778 41.1 0.33 0.17 0.9 0.8 0.7 0.54 0.38 1.0 5.0 e e 1 e e d 1 42 22 21 b z seating plane a l a 2 a 1 b 1 e 1 c
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 # 3-78 appendix 3850/3851 group users manual 3.10 machine instructions when t = 0, this instruction adds the contents m, c, and a; and stores the results in a and c. when t = 1, this instruction adds the contents of m(x), m and c; and stores the results in m(x) and c. when t=1, the contents of a re- main unchanged, but the contents of status flags are changed. m(x) represents the contents of memory where is indicated by x. when t = 0, this instruction transfers the con- tents of a and m to the alu which performs a bit-wise and operation and stores the result back in a. when t = 1, this instruction transfers the con- tents m(x) and m to the alu which performs a bit-wise and operation and stores the results back in m(x). when t = 1 the contents of a re- main unchanged, but status flags are changed. m(x) represents the contents of memory where is indicated by x. this instruction shifts the content of a or m by one bit to the left, with bit 0 always being set to 0 and bit 7 of a or m always being contained in c. this instruction tests the designated bit i of m or a and takes a branch if the bit is 0. the branch address is specified by a relative ad- dress. if the bit is 1, next instruction is executed. this instruction tests the designated bit i of the m or a and takes a branch if the bit is 1. the branch address is specified by a relative ad- dress. if the bit is 0, next instruction is executed. this instruction takes a branch to the ap- pointed address if c is 0. the branch address is specified by a relative address. if c is 1, the next instruction is executed. this instruction takes a branch to the ap- pointed address if c is 1. the branch address is specified by a relative address. if c is 0, the next instruction is executed. this instruction takes a branch to the ap- pointed address when z is 1. the branch address is specified by a relative address. if z is 0, the next instruction is executed. this instruction takes a bit-wise logical and of a and m contents; however, the contents of a and m are not modified. the contents of n, v, z are changed, but the contents of a, m remain unchanged. this instruction takes a branch to the ap- pointed address when n is 1. the branch address is specified by a relative address. if n is 0, the next instruction is executed. this instruction takes a branch to the ap- pointed address if z is 0. the branch address is specified by a relative address. if z is 1, the next instruction is executed. adc (note 1) (note 5) and (note 1) asl bbc (note 4) bbs (note 4) bcc (note 4) bcs (note 4) beq (note 4) bit bmi (note 4) bne (note 4) 7 0 c ? ? 0 29 2 2 0a 2 1 03 + 20i 17 + 20i 07 + 20i 06 5 2 25 3 2 3 65 3 2 69 2 2 4 4 2 2 13 + 20i 5 5 3 3 24 when t = 0 a ? a + m + c when t = 1 m(x) ? m(x) + m + c when t = 0 a ? a m when t = 1 m(x) ? m(x) m ai or mi = 0? ai or mi = 1? c = 0? c = 1? z = 1? a m n = 1? z = 0? v v v 2 3.10 machine instructions bit, a, r bit, zp, r
addressing mode zp, x zp, y abs abs, x abs, y ind zp, ind ind, x ind, y rel sp 7 6 5 4 3 2 1 0 proc essor st atus register nvtbd i zc op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # 3850/3851 group users manual 3-79 appendix 3.10 machine instructions 75 35 16 4 4 6 2 2 2 6d 2d 0e 2c 4 4 6 4 3 3 3 3 7d 3d 1e 5 5 7 3 3 3 79 39 5 5 3 3 61 21 6 6 2 2 90 b0 f0 2 2 2 2 2 2 71 31 6 6 2 2 n n n ? ? ? ? ? m 7 ? ? v ? ? ? ? ? ? ? m 6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? z z z ? ? ? ? ? z ? ? c ? c ? ? ? ? ? ? ? ? 30 d0 2 2 2 2
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 # 3-80 appendix 3850/3851 group users manual 3.10 machine instructions this instruction takes a branch to the ap- pointed address if n is 0. the branch address is specified by a relative address. if n is 1, the next instruction is executed. this instruction branches to the appointed ad- dress. the branch address is specified by a relative address. when the brk instruction is executed, the cpu pushes the current pc contents onto the stack. the badrs designated in the interrupt vector table is stored into the pc. this instruction takes a branch to the ap- pointed address if v is 0. the branch address is specified by a relative address. if v is 1, the next instruction is executed. this instruction takes a branch to the ap- pointed address when v is 1. the branch address is specified by a relative address. when v is 0, the next instruction is executed. this instruction clears the designated bit i of a or m. this instruction clears c. this instruction clears d. this instruction clears i. this instruction clears t. this instruction clears v. when t = 0, this instruction subtracts the con- tents of m from the contents of a. the result is not stored and the contents of a or m are not modified. when t = 1, the cmp subtracts the contents of m from the contents of m(x). the result is not stored and the contents of x, m, and a are not modified. m(x) represents the contents of memory where is indicated by x. this instruction takes the ones complement of the contents of m and stores the result in m. this instruction subtracts the contents of m from the contents of x. the result is not stored and the contents of x and m are not modified. this instruction subtracts the contents of m from the contents of y. the result is not stored and the contents of y and m are not modified. this instruction subtracts 1 from the contents of a or m. bpl (note 4) bra brk bvc (note 4) bvs (note 4) clb clc cld cli clt clv cmp (note 3) com cpx cpy dec n = 0? pc ? pc offset b ? 1 (pc) ? (pc) + 2 m(s) ? pc h s ? s C 1 m(s) ? pc l s ? s C 1 m(s) ? ps s ? s C 1 i ? 1 pc l ? ad l pc h ? ad h v = 0? v = 1? ai or mi ? 0 c ? 0 d ? 0 i ? 0 t ? 0 v ? 0 when t = 0 a C m when t = 1 m(x) C m __ m ? m x C m y C m a ? a C 1 or m ? m C 1 18 d8 58 12 b8 2 2 2 2 2 1 1 1 1 1 c9 e0 c0 2 2 2 2 2 2 1a 2 1 1b + 20i c5 44 e4 c4 c6 3 5 3 3 5 2 2 2 2 2 1f + 20i 21 52 00 7 1
addressing mode zp, x zp, y abs abs, x abs, y ind zp, ind ind, x ind, y rel sp 7 6 5 4 3 2 1 0 proc essor st atus register nvtbd i zc op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # 3850/3851 group users manual 3-81 appendix 3.10 machine instructions d5 d6 cd ec cc ce 50 70 2 2 2 2 ? ? ? ? ? ? ? ? ? ? ? n n n n n ? ? ? ? ? ? ? ? ? ? 0 ? ? ? ? ? 4 6 4 4 4 6 3 3 3 3 dd de 5 7 3 3 d9 5 3 c1 6 2 d1 6 2 ? ? ? ? ? ? ? ? ? 0 ? ? ? ? ? ? ? ? 1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0 ? ? ? ? ? ? ? ? ? ? 1 ? ? ? ? ? 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? z z z z z ? ? ? ? ? ? 0 ? ? ? ? c ? c c ? 2 2 10 80 2 4 2 2
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 # 3-82 appendix 3850/3851 group users manual 3.10 machine instructions this instruction subtracts one from the current contents of x. this instruction subtracts one from the current contents of y. divides the 16-bit data in m(zz+(x)) (low-order byte) and m(zz+(x)+1) (high-order byte) by the contents of a. the quotient is stored in a and the one's complement of the remainder is pushed onto the stack. when t = 0, this instruction transfers the con- tents of the m and a to the alu which performs a bit-wise exclusive or, and stores the result in a. when t = 1, the contents of m(x) and m are transferred to the alu, which performs a bit- wise exclusive or and stores the results in m(x). the contents of a remain unchanged, but status flags are changed. m(x) represents the contents of memory where is indicated by x. this instruction adds one to the contents of a or m. this instruction adds one to the contents of x. this instruction adds one to the contents of y. this instruction jumps to the address desig- nated by the following three addressing modes: absolute indirect absolute zero page indirect absolute this instruction stores the contents of the pc in the stack, then jumps to the address desig- nated by the following addressing modes: absolute special page zero page indirect absolute when t = 0, this instruction transfers the con- tents of m to a. when t = 1, this instruction transfers the con- tents of m to (m(x)). the contents of a remain unchanged, but status flags are changed. m(x) represents the contents of memory where is indicated by x. this instruction loads the immediate value in m. this instruction loads the contents of m in x. this instruction loads the contents of m in y. dex dey div eor (note 1) inc inx iny jmp jsr lda (note 2) ldm ldx ldy x ? x C 1 y ? y C 1 a ? (m(zz + x + 1), m(zz + x )) / a m(s) ? one's comple- ment of remainder s ? s C 1 when t = 0 a ? a v C m when t = 1 m(x) ? m(x) v C m a ? a + 1 or m ? m + 1 x ? x + 1 y ? y + 1 if addressing mode is abs pc l ? ad l pc h ? ad h if addressing mode is ind pc l ? m (ad h , ad l ) pc h ? m (ad h , ad l + 1) if addressing mode is zp, ind pc l ? m(00, ad l ) pc h ? m(00, ad l + 1) m(s) ? pc h s ? s C 1 m(s) ? pc l s ? s C 1 after executing the above, if addressing mode is abs, pc l ? ad l pc h ? ad h if addressing mode is sp, pc l ? ad l pc h ? ff if addressing mode is zp, ind, pc l ? m(00, ad l ) pc h ? m(00, ad l + 1) when t = 0 a ? m when t = 1 m(x) ? m m ? nn x ? m y ? m 3a 21 1 1 1 1 2 2 2 2 ca 88 e8 c8 45 e6 3 5 2 2 49 2 2 a9 a2 a0 a5 3c a6 a4 3 4 3 3 2 3 2 2 2 2 2 2 2 2
addressing mode zp, x zp, y abs abs, x abs, y ind zp, ind ind, x ind, y rel sp 7 6 5 4 3 2 1 0 proc essor st atus register nvtbd i zc op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # 3850/3851 group users manual 3-83 appendix 3.10 machine instructions e2 16 2 4d ee 4 6 3 3 5d fe 5 7 3 3 59 5 3 n n ? n n n n ? ? n ? n n ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? z z ? z z z z ? ? z ? z z ? ? ? ? ? ? ? ? ? ? ? ? ? 41 6 2 51 6 2 b5 b4 4c 20 ad ae ac 6c a1 4 4 2 2 b6 4 2 3 6 4 4 4 3 3 3 3 3 bd bc 5 5 b9 be 5 5 3 3 3 3 53b2 02 4 7 2 2 62b162 22 5 2 55 f6 4 6 2 2
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 # 3-84 appendix 3850/3851 group users manual 3.10 machine instructions this instruction shifts either a or m one bit to the right such that bit 7 of the result always is set to 0, and the bit 0 is stored in c. multiplies accumulator with the memory speci- fied by the zero page x address mode and stores the high-order byte of the result on the stack and the low-order byte in a. this instruction adds one to the pc but does no otheroperation. when t = 0, this instruction transfers the con- tents of a and m to the alu which performs a bit-wise or, and stores the result in a. when t = 1, this instruction transfers the con- tents of m(x) and the m to the alu which performs a bit-wise or, and stores the result in m(x). the contents of a remain unchanged, but status flags are changed. m(x) represents the contents of memory where is indicated by x. this instruction pushes the contents of a to the memory location designated by s, and decrements the contents of s by one. this instruction pushes the contents of ps to the memory location designated by s and dec- rements the contents of s by one. this instruction increments s by one and stores the contents of the memory designated by s in a. this instruction increments s by one and stores the contents of the memory location designated by s in ps. this instruction shifts either a or m one bit left through c. c is stored in bit 0 and bit 7 is stored in c. this instruction shifts either a or m one bit right through c. c is stored in bit 7 and bit 0 is stored in c. this instruction rotates 4 bits of the m content to the right. this instruction increments s by one, and stores the contents of the memory location designated by s in ps. s is again incremented by one and stores the contents of the memory location designated by s in pc l . s is again incremented by one and stores the contents of memory location designated by s in pc h . this instruction increments s by one and stores the contents of the memory location designated by s in pc l . s is again incremented by one and the contents of the memory location is stored in pc h . pc is incremented by 1. lsr mul nop ora (note 1) pha php pla plp rol ror rrf rti rts m(s) ? a ? a ] m(zz + x) s ? s C 1 pc ? pc + 1 when t = 0 a ? a v m when t = 1 m(x) ? m(x) v m s ? s C 1 m(s) ? ps s ? s C 1 s ? s + 1 a ? m(s) s ? s + 1 ps ? m(s) s ? s + 1 ps ? m(s) s ? s + 1 pc l ? m(s) s ? s + 1 pc h ? m(s) s ? s + 1 pc l ? m(s) s ? s + 1 pc h ? m(s) (pc) ? (pc) + 1 7 0 ? ? c ? 7 0 ? ? 7 0 c ? ? 7 0 0 ? ? c 4a 2 1 ea 2 1 09 2 2 46 05 5 3 2 2 2a 6a 26 66 82 48 08 68 28 40 60 3 3 4 4 6 6 1 1 1 1 1 1 2 2 1 1 5 5 8 2 2 2
addressing mode zp, x zp, y abs abs, x abs, y ind zp, ind ind, x ind, y rel sp 7 6 5 4 3 2 1 0 proc essor st atus register nvtbd i zc op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # 3850/3851 group users manual 3-85 appendix 3.10 machine instructions 0 ? ? n ? ? n n n ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? z ? ? z ? ? z z z ? ? c ? ? ? ? ? ? c c ? ? 56 62 15 6 15 4 2 2 2 4e 0d 6 4 3 3 5e 1d 7 5 3 3 19 53 01 6 2 11 6 2 36 76 2e 6e 6 6 2 2 6 6 3 3 3e 7e 7 7 3 3 (value saved in stack) (value saved in stack)
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 # 3-86 appendix 3850/3851 group users manual 3.10 machine instructions when t = 0, this instruction subtracts the value of m and the complement of c from a, and stores the results in a and c. when t = 1, the instruction subtracts the con- tents of m and the complement of c from the contents of m(x), and stores the results in m(x) and c. a remain unchanged, but status flag are changed. m(x) represents the contents of memory where is indicated by x. this instruction sets the designated bit i of a or m. this instruction sets c. this instruction set d. this instruction set i. this instruction set t. this instruction stores the contents of a in m. the contents of a does not change. this instruction resets the oscillation control f/ f and the oscillation stops. reset or interrupt input is needed to wake up from this mode. this instruction stores the contents of x in m. the contents of x does not change. this instruction stores the contents of y in m. the contents of y does not change. this instruction stores the contents of a in x. the contents of a does not change. this instruction stores the contents of a in y. the contents of a does not change. this instruction tests whether the contents of m are 0 or not and modifies the n and z. this instruction transfers the contents of s in x. this instruction stores the contents of x in a. this instruction stores the contents of x in s. this instruction stores the contents of y in a. the wit instruction stops the internal clock but not the oscillation of the oscillation circuit is not stopped. cpu starts its function after the timer x over flows (comes to the terminal count). all regis- ters or internal memory contents except timer x will not change during this mode. (of course needs vdd). sbc (note 1) (note 5) seb sec sed sei set sta stp stx sty tax tay tst tsx txa txs tya wit when t = 0 _ a ? a C m C c when t = 1 _ m(x) ? m(x) C m C c ai or mi ? 1 c ? 1 d ? 1 i ? 1 t ? 1 m ? a m ? x m ? y x ? a y ? a m = 0? x ? s a ? x s ? x a ? y 85 86 84 64 4 4 4 3 2 2 2 2 notes 1 : the number of cycles n is increased by 3 when t is 1. 2 : the number of cycles n is increased by 2 when t is 1. 3 : the number of cycles n is increased by 1 when t is 1. 4 : the number of cycles n is increased by 2 when branching has occurred. 5 : n, v, and z flags are invalid in decimal operation mode. e9 2 2 0b + 20i 0f + 20i 21 52 e5 3 2 38 f8 78 32 2 2 2 2 1 1 1 1 42 aa a8 ba 8a 9a 98 c2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1
addressing mode zp, x zp, y abs abs, x abs, y ind zp, ind ind, x ind, y rel sp 7 6 5 4 3 2 1 0 proc essor st atus register nvtbd i zc op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # 3850/3851 group users manual 3-87 appendix 3.10 machine instructions ? ? ? ? n n n n n ? n ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? z z z z z ? z ? ? ? ? ? ? ? ? ? ? ? ? ? 3 35 fd 4 ed 2 4 f5 f9 5 3 e1 6 2 f1 6 2 95 94 5 5 2 2 96 5 2 8d 8e 8c 5 5 5 3 3 3 9d 6 3 99 6 3 81 7 2 91 7 2 n ? ? ? ? ? v ? ? ? ? ? ? ? ? ? ? 1 ? ? ? ? ? ? ? ? ? 1 ? ? ? ? ? ? 1 ? z ? ? ? ? ? c ? 1 ? ? ?
addition subtraction multiplication division logical or logical and logical exclusive or negation shows direction of data flow index register x index register y stack pointer program counter processor status register 8 high-order bits of program counter 8 low-order bits of program counter 8 high-order bits of address 8 low-order bits of address ff in hexadecimal notation immediate value zero page address memory specified by address designation of any ad- dressing mode memory of address indicated by contents of index register x memory of address indicated by contents of stack pointer contents of memory at address indicated by ad h and ad l , in ad h is 8 high-order bits and ad l is 8 low-or- der bits. contents of address indicated by zero page ad l bit i (i = 0 to 7) of accumulator bit i (i = 0 to 7) of memory opcode number of cycles number of bytes implied addressing mode immediate addressing mode accumulator or accumulator addressing mode accumulator bit addressing mode accumulator bit relative addressing mode zero page addressing mode zero page bit addressing mode zero page bit relative addressing mode zero page x addressing mode zero page y addressing mode absolute addressing mode absolute x addressing mode absolute y addressing mode indirect absolute addressing mode zero page indirect absolute addressing mode indirect x addressing mode indirect y addressing mode relative addressing mode special page addressing mode carry flag zero flag interrupt disable flag decimal mode flag break flag x-modified arithmetic mode flag overflow flag negative flag imp imm a bit, a bit, a, r zp bit, zp bit, zp, r zp, x zp, y abs abs, x abs, y ind zp, ind ind, x ind, y rel sp c z i d b t v n symbol contents symbol contents + C ] / v v C C ? x y s pc ps pc h pc l ad h ad l ff nn zz m m(x) m(s) m(ad h , ad l ) m(00, ad l ) ai mi op n # v 3-88 appendix 3851 group users manual 3.10 machine instructions
3850/3851 group users manual 3-89 appendix 3.11 list of instruction code 3.11 list of instruction code d 7 C d 4 d 3 C d 0 hexadecimal notation 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0 1 2 3 4 5 6 7 8 9 a b c d e f 0000 0 brk bpl jsr abs bmi rti bvc rts bvs bra bcc ldy imm bcs cpy imm bne cpx imm beq 0001 1 ora ind, x ora ind, y and ind, x and ind, y eor ind, x eor ind, y adc ind, x adc ind, y sta ind, x sta ind, y lda ind, x lda ind, y cmp ind, x cmp ind, y sbc ind, x sbc ind, y 0010 2 jsr zp, ind clt jsr sp set stp mul zp, x rrf zp ldx imm jmp zp, ind wit div zp, x 0011 3 bbs 0, a bbc 0, a bbs 1, a bbc 1, a bbs 2, a bbc 2, a bbs 3, a bbc 3, a bbs 4, a bbc 4, a bbs 5, a bbc 5, a bbs 6, a bbc 6, a bbs 7, a bbc 7, a 0100 4 bit zp com zp tst zp sty zp sty zp, x ldy zp ldy zp, x cpy zp cpx zp 0101 5 ora zp ora zp, x and zp and zp, x eor zp eor zp, x adc zp adc zp, x sta zp sta zp, x lda zp lda zp, x cmp zp cmp zp, x sbc zp sbc zp, x 0110 6 asl zp asl zp, x rol zp rol zp, x lsr zp lsr zp, x ror zp ror zp, x stx zp stx zp, y ldx zp ldx zp, y dec zp dec zp, x inc zp inc zp, x 0111 7 bbs 0, zp bbc 0, zp bbs 1, zp bbc 1, zp bbs 2, zp bbc 2, zp bbs 3, zp bbc 3, zp bbs 4, zp bbc 4, zp bbs 5, zp bbc 5, zp bbs 6, zp bbc 6, zp bbs 7, zp bbc 7, zp 1000 8 php clc plp sec pha cli pla sei dey tya tay clv iny cld inx sed 1001 9 ora imm ora abs, y and imm and abs, y eor imm eor abs, y adc imm adc abs, y sta abs, y lda imm lda abs, y cmp imm cmp abs, y sbc imm sbc abs, y 1010 a asl a dec a rol a inc a lsr a ror a txa txs tax tsx dex nop 1011 b seb 0, a clb 0, a seb 1, a clb 1, a seb 2, a clb 2, a seb 3, a clb 3, a seb 4, a clb 4, a seb 5, a clb 5, a seb 6, a clb 6, a seb 7, a clb 7, a 1100 c bit abs ldm zp jmp abs jmp ind sty abs ldy abs ldy abs, x cpy abs cpx abs 1101 d ora abs ora abs, x and abs and abs, x eor abs eor abs, x adc abs adc abs, x sta abs sta abs, x lda abs lda abs, x cmp abs cmp abs, x sbc abs sbc abs, x 1 110 e asl abs asl abs, x rol abs rol abs, x lsr abs lsr abs, x ror abs ror abs, x stx abs ldx abs ldx abs, y dec abs dec abs, x inc abs inc abs, x 1111 f seb 0, zp clb 0, zp seb 1, zp clb 1, zp seb 2, zp clb 2, zp seb 3, zp clb 3, zp seb 4, zp clb 4, zp seb 5, zp clb 5, zp seb 6, zp clb 6, zp seb 7, zp clb 7, zp : 3-byte instruction : 2-byte instruction : 1-byte instruction
3-90 appendix 3850/3851 group users manual 3.12 sfr memory map 3.12 sfr memory map 0020 16 0021 16 0022 16 0023 16 0024 16 0025 16 0026 16 0027 16 0028 16 0029 16 002a 16 002b 16 002c 16 002d 16 002e 16 002f 16 0030 16 0031 16 0032 16 0033 16 0034 16 0035 16 0036 16 0037 16 0038 16 0039 16 003a 16 003b 16 003c 16 003d 16 003e 16 003f 16 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 0010 16 0011 16 0012 16 0013 16 0014 16 0015 16 0016 16 0017 16 0018 16 0019 16 001a 16 001b 16 001c 16 001d 16 001e 16 001f 16 port p0 (p0) port p0 direction register (p0d) port p1 (p1) port p1 direction register (p1d) port p2 (p2) port p2 direction register (p2d) port p3 (p3) port p3 direction register (p3d) port p4 (p4) port p4 direction register (p4d) transmit/receive buffer register (tb/rb) serial i/o status register (siosts) serial i/o control register (siocon) uart control register (uartcon) baud rate generator (brg) interrupt control register 2 (icon2) a-d conversion low-order register (adl) prescaler y (prey) timer y (ty) a-d control register (adcon) a-d conversion high-order register (adh) interrupt edge selection register (intedge) cpu mode register (cpum) interrupt request register 1 (ireq1) interrupt request register 2 (ireq2) interrupt control register 1 (icon1) prescaler 12 (pre12) timer 2 (t2) prescaler x (prex) timer x (tx) timer 1 (t1) timer xy mode register (tm) i 2 c data shift register (s0) i 2 c address register (s0d) i 2 c status register (s1) i 2 c control register (s1d) i 2 c clock control register (s2) i 2 c start/stop condition control register (s2d) misrg watchdog timer control register (wdtcon) pwm control register (pwmcon) pwm prescaler (prepwm) pwm register (pwm) timer count source selection register (tcss) reserved ] reserved ] reserved ] ] reserved : do not write ??to this address. reserved ]
3850/3851 group users manual 3-91 appendix 3.13 pin configurations 3.13 pin configurations fig. 3.13.1 m38513m4-xxxfp/sp pin configuration p4 0 /cntr 1 p4 1 /int 0 p4 2 /int 1 p4 3 /int 2 av ss p4 4 /int 3 /pwm v ref v cc p3 1 /an 1 p3 2 /an 2 p0 0 p0 4 p0 5 p0 6 p0 7 p1 1 p1 2 p1 3 /(led 0 ) p1 4 /(led 1 ) p1 5 /(led 2 ) p1 0 p0 1 p0 2 p3 0 /an 0 p3 3 /an 3 p3 4 /an 4 p0 3 40 41 42 22 23 24 25 26 27 28 29 30 31 32 34 35 36 37 38 39 33 3 2 1 21 20 19 18 17 16 15 14 13 12 11 9 8 7 6 5 4 10 m38513m4-xxxfp m38513m4-xxxsp p1 6 /(led 3 ) p1 7 /(led 4 ) p2 7 /cntr 0 /s rdy p2 6 /s clk p2 5 /scl 2 /txd p2 4 /sda 2 /rxd p2 3 /scl 1 p2 2 /sda 1 cnv ss p2 1 /x cin p2 0 /x cout reset x in x out v ss package type : fp ........................... 42p2r-a (42-pin plastic-molded ssop) package type : sp ........................... 42p4b (42-pin shrink plastic-molded dip) pin configuration (top view)
3-92 appendix 3850/3851 group users manual 3.13 pin configurations memorandum
mitsubishi semiconductors users manual 3850/3851 group oct. first edition 1998 editioned by committee of editing of mitsubishi semiconductor users 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. ?1998 mitsubishi electric corporation
users manual 3850/3851 group ? 1998 mitsubishi electric corporation. new publication, effective oct. 1998. specifications subject to change without notice.


▲Up To Search▲   

 
Price & Availability of 3850

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X