User's Manual V850ES/Fx3-L 32-bit Single-Chip Microcontroller Hardware V850ES/FE3-L: V850ES/FF3-L: V850ES/FG3-L: PD70F3615 PD70F3610 PD70F3620 PD70F3611 PD70F3616 PD70F3621 PD70F3612 PD70F3617 PD70F3622 PD70F3613 PD70F3618 PD70F3614 PD70F3619 Document No. U18743EE1V2UM00 Date Published June 2008 (c) NEC Electronics 2008 Printed in Germany User's Manual U18743EE1V2UM00 2 Notes for CMOS Devices 1. Precaution against ESD for semiconductors Strong electric field, when exposed to a MOS device, can cause destruction of the gate oxide and ultimately degrade the device operation. Steps must be taken to stop generation of static electricity as much as possible, and quickly dissipate it once, when it has occurred. Environmental control must be adequate. When it is dry, humidifier should be used. It is recommended to avoid using insulators that easily build static electricity. Semiconductor devices must be stored and transported in an anti-static container, static shielding bag or conductive material. All test and measurement tools including work bench and floor should be grounded. The operator should be grounded using wrist strap. Semiconductor devices must not be touched with bare hands. Similar precautions need to be taken for PW boards with semiconductor devices on it. 2. Handling of unused input pins for CMOS No connection for CMOS device inputs can be cause of malfunction. If no connection is provided to the input pins, it is possible that an internal input level may be generated due to noise, etc., hence causing malfunction. CMOS devices behave differently than Bipolar or NMOS devices. Input levels of CMOS devices must be fixed high or low by using a pull-up or pulldown circuitry. Each unused pin should be connected to VDD or GND with a resistor, if it is considered to have a possibility of being an output pin. All handling related to the unused pins must be judged device by device and related specifications governing the devices. 3. Status before initialization of MOS devices Power-on does not necessarily define initial status of MOS device. Production process of MOS does not define the initial operation status of the device. Immediately after the power source is turned ON, the devices with reset function have not yet been initialized. Hence, power-on does not guarantee out-pin levels, I/O settings or contents of registers. Device is not initialized until the reset signal is received. Reset operation must be executed immediately after power-on for devices having reset function. User's Manual U18743EE1V2UM00 3 Legal Notes * The information in this document is current as of June 2008. The information is subject to change without notice. For actual design-in, refer to the latest publications of NEC Electronics data sheets or data books, etc., for the most up-to-date specifications of NEC Electronics products. Not all products and/ or types are available in every country. Please check with an NEC sales representative for availability and additional information. * No part of this document may be copied or reproduced in any form or by any means without prior written consent of NEC Electronics. NEC Electronics assumes no responsibility for any errors that may appear in this document. * NEC Electronics does not assume any liability for infringement of patents, copyrights or other intellectual property rights of third parties by or arising from the use of NEC Electronics products listed in this document or any other liability arising from the use of such NEC Electronics products. No license, express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of NEC Electronics or others. * Descriptions of circuits, software and other related information in this document are provided for illustrative purposes in semiconductor product operation and application examples. The incorporation of these circuits, software and information in the design of customer's equipment shall be done under the full responsibility of customer. NEC Electronics assumes no responsibility for any losses incurred by customers or third parties arising from the use of these circuits, software and information. * While NEC Electronics endeavors to enhance the quality, reliability and safety of NEC Electronics products, customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. To minimize risks of damage to property or injury (including death) to persons arising from defects in NEC Electronics products, customers must incorporate sufficient safety measures in their design, such as redundancy, firecontainment and anti-failure features. * NEC Electronics products are classified into the following three quality grades: "Standard", "Special" and "Specific". The "Specific" quality grade applies only to NEC Electronics products developed based on a customer-designated "quality assurance program" for a specific application. The recommended applications of NEC Electronics product depend on its quality grade, as indicated below. Customers must check the quality grade of each NEC Electronics product before using it in a particular application. "Standard": Computers, office equipment, communications equipment, test and measurement equipment, audio and visual equipment, home electronic appliances, machine tools, personal electronic equipment and industrial robots. "Special": Transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support). "Specific": Aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life support systems and medical equipment for life support, etc. 4 User's Manual U18743EE1V2UM00 The quality grade of NEC Electronics products is "Standard" unless otherwise expressly specified in NEC Electronics data sheets or data books, etc. If customers wish to use NEC Electronics products in applications not intended by NEC Electronics, they must contact NEC Electronics sales representative in advance to determine NEC Electronics 's willingness to support a given application. Note 1. "NEC Electronics" as used in this statement means NEC Electronics Corporation and also includes its majority-owned subsidiaries. 2. "NEC Electronics products" means any product developed or manufactured by or for NEC Electronics (as defined above). 3. SuperFlash(R) is a registered trademark of Silicon Storage Technology, Inc. in several countries including the United States and Japan. This product uses SuperFlash(R) technology licensed from Silicon Storage Technology, Inc. Caution This document is a draft (a momentary snapshot) of a document under work. Future versions of this document will not hold a history list of changes towards this draft document. User's Manual U18743EE1V2UM00 5 Regional Information Some information contained in this document may vary from country to country. Before using any NEC product in your application, please contact the NEC office in your country to obtain a list of authorized representatives and distributors. They will verify: * * * * * Device availability Ordering information Product release schedule Availability of related technical literature Development environment specifications (for example, specifications for third-party tools and components, host computers, power plugs, AC supply voltages, and so forth) * Network requirements In addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary from country to country. For further information please contact: NEC Electronics Corporation 1753, Shimonumabe, Nakahara-ku, Kawasaki, Kanagawa 211-8668, Japan Tel: 044 4355111 http://www.necel.com/ [America] [Europe] [Asia & Oceania] NEC Electronics America, Inc. 2880 Scott Blvd. Santa Clara, CA 95050-2554,| U.S.A. Tel: 408 5886000 http://www.am.necel.com/ NEC Electronics (Europe) GmbH Arcadiastrasse 10 40472 Dusseldorf, Germany Tel: 0211 6503-0 http://www.eu.necel.com/ NEC Electronics (China) Co., Ltd 7th Floor, Quantum Plaza, No. 27 ZhiChunLu Haidian District, Beijing 100083, P.R.China Tel: 010 82351155 http://www.cn.necel.com/ United Kingdom Branch Cygnus House, Sunrise Parkway Linford Wood Milton Keynes, MK14 6NP, U.K. Tel: 01908 691133 Succursale Francaise 9, rue Paul Dautier, B.P. 52 78142 Velizy-Villacoublay Cedex France Tel: 01 30675800 Tyskland Filial Taby Centrum Entrance S (7th floor) 18322 Taby, Sweden Tel: 08 6387200 Filiale Italiana Via Fabio Filzi, 25A 20124 Milano, Italy Tel: 02 667541 Branch The Netherlands Steijgerweg 6 5616 HS Eindhoven, The Netherlands Tel: 040 2654010 NEC Electronics Shanghai Ltd. Room 2511-2512, Bank of China Tower, 200 Yincheng Road Central, Pudong New Area, Shanghai 200120, P.R. China Tel: 021 5888 5400 http://www.cn.necel.com/ NEC Electronics Hong Kong Ltd. Unit 1601-1613, 16/F., Tower 2 Grand Century Place 193 Prince Edward Road West, Mongkok, Kowloon, Hong Kong Tel: 2886 9318 http://www.hk.necel.com/ NEC Electronics Taiwan Ltd. 7F, No. 363 Fu Shing North Road Taipei, Taiwan, R.O.C. Tel: 02 8175-9600 NEC Electronics Singapore Pte. Ltd. 238A Thomson Road, #12-08 Novena Square, Singapore 307684 Tel: 6253-8311 http://www.sg.necel.com/ NEC Electronics Korea Ltd. 11F., Samik Lavied'or Bldg., 720-2, Yeoksam-Dong, Kangnam-Ku, Seoul, 135-080, Korea Tel: 02-558-3737 http://www.kr.necel.com/ 6 User's Manual U18743EE1V2UM00 Preface Readers This manual is intended for users who want to understand the functions of the concerned microcontrollers. Purpose This manual presents the hardware manual for the concerned microcontrollers. Organization Module instances Legend Note Caution Numeric notation: Prefixes Register contents: Diagrams This system specification describes the following sections: * Pin function * CPU function * Internal peripheral function These microcontrollers may contain several instances of a dedicated module. In general the different instances of such modules are identified by the index "n", where "n" counts from 0 to the number of instances minus one. Symbols and notation are used as follows: * Weight in data notation: Left is high order column, right is low order column * Active low notation: xxx (pin or signal name is over-scored) or /xxx (slash before signal name) * Memory map address: High order at high stage and low order at low stage Additional remark or tip Item deserving extra attention * Binary: * Decimal: * Hexadecimal: xxxx or xxxB xxxx xxxxH or 0x xxxx representing powers of 2 (address space, memory capacity): * K (kilo): 210 = 1024 * M (mega): 220 = 10242 = 1,048,576 * G (giga): 230 = 10243 = 1,073,741,824 X, x = don't care Block diagrams do not necessarily show the exact wiring in hardware but the functional structure. Timing diagrams are for functional explanation purposes only, without any relevance to the real hardware implementation. User's Manual U18743EE1V2UM00 7 Related documents The related documents indicated in this publication may include preliminary versions. Preliminary versions are not marked as such. Document name Document No. V850ES User's Manual Architecture U15943EJ3V0UM00 Self-Programming Application Note U16929EE3V0AN00 Refer to http://www.eu.necel.com/docuweb/ to obtain the latest version of above documents. Further information 8 For further information see http://www.ee.nec.de. User's Manual U18743EE1V2UM00 Table of Contents Chapter 1 1.1 1.2 1.3 1.4 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Features Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.1 Internal units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.2 Structure of the manual. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ordering Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 V850ES/FE3-L ordering information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.2 V850ES/FF3-L ordering information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.3 V850ES/FG3-L ordering information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 20 23 25 25 27 27 29 30 Chapter 2 2.1 2.2 2.3 2.4 Pin Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.2 Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.3 Noise elimination. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Port Group Configuration Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.2 Pin function configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.3 Pin data input/output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.4 Configuration of pull-up resistors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.5 Open drain configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Port Buffers Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Port Type Diagrams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.1 Port type C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.2 Port type C-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.3 Port type D0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.4 Port type D0-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.5 Port type D1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.6 Port type D1-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.7 Port type D1-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.8 Port type D3-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.9 Port type D1A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.10 Port type D1O1-UI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.11 Port type D2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.12 Port type E01-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.13 Port type E10-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.14 Port type E10-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.15 Port type E11-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.16 Port type E11-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.17 Port type E21-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.18 Port type Ex0-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.19 Port type Ex1-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.20 Port type Ex1-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.21 Port type Ex2-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.22 Port type F010x-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.23 Port type F010x-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 32 35 35 36 36 37 43 45 46 47 51 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 User's Manual U18743EE1V2UM00 9 Table of Contents 2.5 2.6 2.7 2.8 2.9 10 2.4.24 Port type F100x-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 2.4.25 Port type F1010-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 2.4.26 Port type F101x-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 2.4.27 Port type F1100O0-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 2.4.28 Port type F1100O1-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 2.4.29 Port type F1100-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 2.4.30 Port type F1110-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 2.4.31 Port type F113x-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 2.4.32 Port type F1x10-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 2.4.33 Port type F3x1x-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 2.4.34 Port type F1xx0O1-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 2.4.35 Port type Fx010-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 2.4.36 Port type Fx01x-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 2.4.37 Port type Fx103-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 2.4.38 Port type Fx10x-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 2.4.39 Port type Fx10x-UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 2.4.40 Port type Fx110-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 2.4.41 Port type Fx120-UFI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 2.4.42 Port type Fx123-UFI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 2.4.43 Port type Fx12x-UFI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 2.4.44 Port type Fx13x-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 2.4.45 Port type Fx210-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 2.4.46 Port type Fx2x0-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 2.4.47 Port type Fxx10-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 2.4.48 Port type Fxx1x-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 2.4.49 Port type Fxx2x-U . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Port Group Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 2.5.1 Port group configuration lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 2.5.2 Alphabetic pin function list. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 2.5.3 Port group 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 2.5.4 Port group 1 (V850ES/FG3-L). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 2.5.5 Port group 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 2.5.6 Port group 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 2.5.7 Port group 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 2.5.8 Port group 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 2.5.9 Port group 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 2.5.10 Port group CM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 2.5.11 Port group CS (V850ES/FF3-L, V850ES/FG3-L) . . . . . . . . . . . . . . . . . . . . 123 2.5.12 Port group CT (V850ES/FF3-L, V850ES/FG3-L) . . . . . . . . . . . . . . . . . . . . 124 2.5.13 Port group DL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Noise Elimination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 2.6.1 Analog filtered inputs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 2.6.2 Digitally filtered inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Pin Functions in Reset and Power Save Modes. . . . . . . . . . . . . . . . . . . . . . . . . . 130 Recommended Connection of unused Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Package Pins Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 2.9.1 V850ES/FE3-L package pins assignment. . . . . . . . . . . . . . . . . . . . . . . . . . 132 2.9.2 V850ES/FF3-L package pins assignment. . . . . . . . . . . . . . . . . . . . . . . . . . 133 2.9.3 V850ES/FG3-L package pins assignment . . . . . . . . . . . . . . . . . . . . . . . . . 134 User's Manual U18743EE1V2UM00 Table of Contents Chapter 3 3.1 3.2 3.3 3.4 3.5 3.6 CPU System Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CPU Register Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 General purpose registers (r0 to r31) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.2 System register set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operation Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 Normal operation mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.2 Flash programming mode (flash memory devices only) . . . . . . . . . . . . . . . 3.3.3 On-Chip debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Address Space. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.1 CPU address space and physical address space . . . . . . . . . . . . . . . . . . . . 3.4.2 Program and data space. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.1 Memory areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.2 Recommended use of data address space. . . . . . . . . . . . . . . . . . . . . . . . . Write Protected Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6.1 Write protection control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 136 137 138 139 146 146 146 146 147 147 149 151 151 154 155 157 Chapter 4 4.1 4.2 4.3 Clock Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1.2 Clock Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1.3 Power save modes overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1.4 Start conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Clock Generator Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.1 General Clock Generator registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.2 PLL control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.3 Stand-by control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.4 Prescaler3 control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.5 Clock Monitor control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.6 Selector control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Option Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3.1 Option byte 0000 007AH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 160 163 164 165 166 168 178 181 183 184 185 188 189 4.3.2 4.4 Clock Generator Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.1 Overview of clock operation control settings. . . . . . . . . . . . . . . . . . . . . . . . 4.4.2 Operation state transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.3 Power save modes description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.4 Available clocks in power save modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.5 Power save mode activation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.6 Controlling the PLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.7 Watch Dog Timer Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.8 CLKOUT function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.9 Operation of Prescaler3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.10 Operation of the Clock Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 5 5.1 Option byte 0000 007BH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 Interrupt Controller (INTC) . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 191 192 196 211 213 215 215 215 216 217 221 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 User's Manual U18743EE1V2UM00 11 Table of Contents 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 Non-Maskable Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.1 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.2 Restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.3 Non-maskable interrupt status flag (NP) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4 NMI control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Maskable Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.1 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.2 Restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.3 Priorities of maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.4 xxICn - Maskable interrupt control registers . . . . . . . . . . . . . . . . . . . . . . . . 5.3.5 IMRm - Interrupt mask registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.6 ISPR - In-service priority register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.7 Maskable interrupt status flag (ID) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.8 External maskable interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . External Interrupts Edge Detection Configuration. . . . . . . . . . . . . . . . . . . . . . . . Software Exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.5.1 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.5.2 Restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.5.3 Exception status flag (EP). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exception Trap. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.6.1 Illegal opcode definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.6.2 Debug trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multiple Interrupt Processing Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interrupt Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Periods in which interrupts are not acknowledged . . . . . . . . . . . . . . . . . . . . . . . Chapter 6 6.1 6.2 6.3 7.2 7.3 7.4 7.5 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 Cautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 Chapter 7 7.1 Key Interrupt Function 224 227 228 229 229 230 230 232 233 237 240 242 243 243 244 247 247 248 249 249 249 251 252 254 255 Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 Code Flash Memory Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.1 Code flash memory features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.2 Code flash memory mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.3 Code flash memory functional outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.4 Code flash memory erasure and rewrite . . . . . . . . . . . . . . . . . . . . . . . . . . . Flash Programming with Flash Programmer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.1 Programming environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.2 Communication mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.3 Pin connection with flash programmer PG-FP4 . . . . . . . . . . . . . . . . . . . . . 7.2.4 Flash memory programming control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Code Flash Self-Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.1 Self-programming enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.2 Self-programming library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.3 Secure self-programming (boot cluster swapping) . . . . . . . . . . . . . . . . . . . 7.3.4 Interrupt handling during flash self-programming . . . . . . . . . . . . . . . . . . . . Variable Reset Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Flash Mask Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . User's Manual U18743EE1V2UM00 260 260 261 262 265 266 266 267 269 271 277 278 278 279 283 284 285 Table of Contents 7.5.1 Chapter 8 8.1 8.2 8.3 PRDSELH register - Product selection code register High . . . . . . . . . . . . . 288 Data Protection and Security . . . . . . . . . . . . . . . . . . . . . . . . 289 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 N-Wire Debug Interface Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Flash Programmer and Self-Programming Protection . . . . . . . . . . . . . . . . . . . . 291 Chapter 9 Bus Control Unit (BCU). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.1.1 Peripheral I/O area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.1.2 NPB access timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.1.3 Bus properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.1.4 Boundary operation conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.2.1 BCU registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 296 298 299 299 301 301 Chapter 10 16-Bit Timer/Event Counter AA. . . . . . . . . . . . . . . . . . . . . . 305 10.1 10.2 10.3 10.4 10.5 10.6 305 306 306 312 314 326 327 331 9.1 9.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Function Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Input Selection Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.6.1 Anytime write and reload. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.6.2 Interval timer mode (TAAnMD2 to TAAnMD0 = 000B) . . . . . . . . . . . . . . . . 10.6.3 External event counter mode (TAAnMD2 to TAAnMD0 = 001B). . . . . . . . . 335 10.6.4 External trigger pulse mode (TAAnMD2 to TAAnMD0 = 010B). . . . . . . . . . 339 10.6.5 One-shot pulse mode (TAAnMD2 to TAAnMD0 = 011B) . . . . . . . . . . . . . . 342 10.6.6 PWM mode (TAAnMD2 to TAAnMD0 = 100B) . . . . . . . . . . . . . . . . . . . . . . 345 10.6.7 Free-running mode (TAAnMD2 to TAAnMD0 = 101B) . . . . . . . . . . . . . . . . 350 10.6.8 Pulse width measurement mode (TAAnMD2 to TAAnMD0 = 110B)356 10.6.9 32-bit Capture in Free-Running Cascade Mode . . . . . . . . . . . . . . . . . . . . . 363 10.6.10 Capture operation on delayed input clock . . . . . . . . . . . . . . . . . . . . . . . . . . 368 Chapter 11 16-Bit Interval Timer M 11.1 11.2 11.3 11.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Timer M Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.4.1 Interval timer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.4.2 Cautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 12 Timer AA Synchroneous Operation . . . . . . . . . . . . . . . . 377 Chapter 13 Watch Timer Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.1 13.2 371 371 372 374 374 375 379 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 User's Manual U18743EE1V2UM00 13 Table of Contents 13.3 13.4 Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.4.1 Operation as Watch Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.4.2 Operation as interval timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.4.3 Cautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 382 382 383 384 Chapter 14 Watchdog Timer 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 14.1 14.2 14.3 14.4 14.5 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Watchdog Timer Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Watchdog Timer Operation in Power Save Mode. . . . . . . . . . . . . . . . . . . . . . . . . 385 386 387 389 390 Chapter 15 Asynchronous Serial Interface (UARTD) . . . . . . . . . . . 391 15.1 15.2 15.3 15.4 15.5 391 392 395 403 404 404 406 408 408 410 412 413 414 416 416 418 419 426 15.6 15.7 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . UARTD Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interrupt Request Signals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.1 Data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.2 SBF transmission/reception format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.3 SBF transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.4 SBF reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.5 Data consistency check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.6 UART transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.7 Continuous transmission procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.8 UART reception. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.9 Reception errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.10 Parity types and operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5.11 Receive data noise filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Baud Rate Generator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 16 Clocked Serial Interface (CSIB) 16.1 16.2 16.3 16.4 16.5 16.6 14 . . . . . . . . . . . . . . . . . . . . . 427 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CSIB Control Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16.4.1 Single transfer mode (master mode, transmission/reception mode). . . . . . 16.4.2 Single transfer mode (master mode, reception mode) . . . . . . . . . . . . . . . . 16.4.3 Continuous mode (master mode, transmission/reception mode) . . . . . . . . 16.4.4 Continuous mode (master mode, reception mode) . . . . . . . . . . . . . . . . . . . 16.4.5 Continuous reception mode (error) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16.4.6 Continuous mode (slave mode, transmission/reception mode) . . . . . . . . . 16.4.7 Continuous mode (slave mode, reception mode) . . . . . . . . . . . . . . . . . . . . 16.4.8 Clock timing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Output Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operation Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . User's Manual U18743EE1V2UM00 427 428 430 436 436 438 439 440 441 442 445 446 448 449 Table of Contents Chapter 17 I2C Bus (IIC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 17.10 17.11 17.12 17.13 17.14 17.15 17.16 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I2C Pin Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IIC Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I2C Bus Mode Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.5.1 Pin functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I2C Bus Definitions and Control Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.6.1 Start condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.6.2 Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.6.3 Transfer direction specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.6.4 Acknowledge signal (ACK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.6.5 Stop condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.6.6 Wait signal (WAIT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I2C Interrupt Request Signals (INTIICn). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.7.1 Master device operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.7.2 Slave device operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.7.3 Slave device operation (when receiving extension code) . . . . . . . . . . . . . . 17.7.4 Operation without communication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.7.5 Arbitration loss operation (operation as slave after arbitration loss) . . . . . . 17.7.6 Operation when arbitration loss occurs . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interrupt Request Signal (INTIICn). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Address Match Detection Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Error Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Extension Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wakeup Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Communication Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.15.1 Master operation 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.15.2 Master operation 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.15.3 Slave operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Timing of Data Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 18 CAN Controller (CAN) 18.1 18.2 18.3 457 457 458 462 480 480 481 481 482 483 483 485 486 488 488 491 495 499 499 501 506 507 507 508 509 510 511 512 512 514 515 519 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.1.1 Overview of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.1.2 Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CAN Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.2.1 Frame format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.2.2 Frame types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.2.3 Data frame and remote frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.2.4 Error frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.2.5 Overload frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.3.1 Determining bus priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.3.2 Bit stuffing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.3.3 Multi masters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.3.4 Multi cast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . User's Manual U18743EE1V2UM00 457 528 529 530 531 531 532 532 539 540 541 541 541 542 542 15 Table of Contents 18.3.5 CAN sleep mode/CAN stop mode function . . . . . . . . . . . . . . . . . . . . . . . . . 18.3.6 Error control function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.3.7 Baud rate control function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Connection with Target System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Internal Registers of CAN Controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.5.1 CAN module register and message buffer addresses . . . . . . . . . . . . . . . . 18.5.2 CAN Controller configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.5.3 CAN registers overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.5.4 Register bit configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bit Set/Clear Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CAN Controller Initialization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.8.1 Initialization of CAN module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.8.2 Initialization of message buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.8.3 Redefinition of message buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.8.4 Transition from initialization mode to operation mode. . . . . . . . . . . . . . . . . 18.8.5 Resetting error counter CnERC of CAN module. . . . . . . . . . . . . . . . . . . . . Message Reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.9.1 Message reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.9.2 Receive data read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.9.3 Receive history list function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.9.4 Mask function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.9.5 Multi buffer receive block function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.9.6 Remote frame reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Message Transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.10.1 Message transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.10.2 Transmit history list function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.10.3 Automatic block transmission (ABT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.10.4 Transmission abort process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.10.5 Remote frame transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Power Saving Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.11.1 CAN sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.11.2 CAN stop mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.11.3 Example of using power saving modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . Interrupt Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Diagnosis Functions and Special Operational Modes. . . . . . . . . . . . . . . . . . . . . 18.13.1 Receive-only mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.13.2 Single-shot mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.13.3 Self-test mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.13.4 Receive/transmit operation in each operation mode. . . . . . . . . . . . . . . . . . Time Stamp Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.14.1 Time stamp function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Baud Rate Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.15.1 Baud rate setting conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.15.2 Representative examples of baud rate settings . . . . . . . . . . . . . . . . . . . . . Operation of CAN Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542 542 549 552 553 553 554 555 557 560 562 598 598 598 598 600 601 602 602 603 604 606 608 609 610 610 612 614 616 617 618 618 621 622 623 624 624 625 626 627 628 628 629 629 633 637 Chapter 19 A/D Converter (ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663 18.4 18.5 18.6 18.7 18.8 18.9 18.10 18.11 18.12 18.13 18.14 18.15 18.16 19.1 19.2 16 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665 User's Manual U18743EE1V2UM00 Table of Contents 19.3 19.4 19.5 19.6 ADC Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19.4.1 Basic operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19.4.2 Trigger mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19.4.3 Operation modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19.4.4 Power-fail compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to read A/D Converter characteristics table . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 20 Power Supply Scheme 20.1 20.2 20.3 667 680 680 681 683 688 694 696 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701 Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702 Voltage regulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 Chapter 21 Reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 21.1 705 705 708 710 711 711 711 712 21.2 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.1 General reset performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.2 Reset at power-on. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.3 External RESET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.4 Reset by Watchdog Timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.5 Reset by Clock Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.6 Reset by Low-Voltage Detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Reset Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 22 Low-Voltage Detector 22.1 22.2 22.3 22.4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.4.1 Reset generation from LVI (LVIM.LVIMD = 1) . . . . . . . . . . . . . . . . . . . . . . 22.4.2 Interrupt generation from LVI (LVIM.LVIMD = 0) . . . . . . . . . . . . . . . . . . . . 22.4.3 Disabling the LVI operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.4.4 RAM retention voltage detection operation . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 23 On-Chip Debug Unit 23.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713 713 713 714 719 719 720 721 722 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 Functional Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.1.1 Debug functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Controlling the N-Wire Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N-Wire Enabling Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.3.1 Starting normal operation after RESET and RESPOC . . . . . . . . . . . . . . . . 23.3.2 Starting debugger after RESET and RESPOC . . . . . . . . . . . . . . . . . . . . . . 23.3.3 N-Wire activation by RESET pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Connection to N-Wire Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.4.1 KEL connector. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Restrictions and Cautions on On-Chip Debug Function . . . . . . . . . . . . . . . . . . . 723 723 726 728 728 728 729 730 730 734 Chapter 24 Differences Fx3-L to Fx3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735 23.2 23.3 23.4 23.5 User's Manual U18743EE1V2UM00 17 Table of Contents Appendix A Special Function Registers. . . . . . . . . . . . . . . . . . . . . . . . . A.1 A.2 18 737 CAN Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737 Other Special Function Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739 Appendix B Registers Access Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749 B.1 B.2 B.3 B.4 B.5 B.6 B.7 B.8 B.9 Timer AA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Timer M. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Watchdog Timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A/D Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I2C Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Asynchronous Serial Interface (UARTD). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Clocked Serial Interface (CSIB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CAN Controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . All other Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749 751 752 752 753 753 753 754 754 Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757 User's Manual U18743EE1V2UM00 Chapter 1 Introduction The V850ES/Fx3-L is a product line in NEC Electronics' V850 family of singlechip microcontrollers designed for automotive applications. 1.1 General The V850ES/Fx3-L single-chip microcontroller devices make the performance gains attainable with 32-bit RISC-based controllers available for embedded control applications. The integrated V850ES CPU offers easy pipeline handling and programming, resulting in compact code size comparable to 16-bit CISC CPUs. The V850ES/Fx3-L devices provide an excellent combination of general purpose peripheral functions like serial communication interfaces, timers/ counters, measurement and control functions, with full CAN network support. The devices offer specific power-saving modes to manage the power consumption effectively under varying conditions. Thus equipped, the V850ES/Fx3-L product line is ideally suited for automotive body applications. It is also an excellent choice for other applications where a combination of sophisticated peripheral functions and CAN network support is required. (1) V850ES CPU The V850ES CPU core is a 32-bit RISC processor. Through the use of basic instructions that can be executed in one clock period combined with an optimized pipeline architecture, it achieves marked improvements in instruction execution speed. In addition, to make it ideal for use in digital control applications, a 32-bit hardware multiplier supports multiply instructions, saturated multiply instructions, bit operation instructions, etc. Through two-byte basic instructions and instructions compatible with high level languages, the object code efficiency in a C compiler is increased, and program size can be reduced. Further, because the on-chip Interrupt Controller provides high-speed interrupt response and processing, the devices are well suited for high level real-time control applications. (2) On-chip flash memory The V850ES/Fx3-L microcontrollers have on-chip flash memory. It is possible to program the controllers directly in the target environment where they are mounted. With this feature, system development time can be reduced and system maintainability after shipping can be markedly improved. User's Manual U18743EE1V2UM00 19 Chapter 1 Introduction (3) A full range of software development tools A development system is available that includes an optimized C compiler, debugger, in-circuit emulator, simulator, system performance analyzer, and other elements. 1.2 Features Summary The V850ES/Fx3-L series includes the following microcontrollers: * V850ES/FE3-L - PD70F3610 - PD70F3611 - PD70F3612 - PD70F3613 - PD70F3614 * V850ES/FF3-L - PD70F3615 - PD70F3616 - PD70F3617 - PD70F3618 - PD70F3619 * V850ES/FG3-L - PD70F3620 - PD70F3621 - PD70F3622 The common CPU core provides: * 81 instructions * 32 general registers (32 bits each) * Comprehensive instruction set: - V850ES (compatible with V850 plus added powerful instructions for reducing code and increasing execution speed) - Signed multiplication (16 bits x 16 bits 32 bits or 32 bits x 32 bits 64 bits) in 1 to 5 clocks - Saturated operation instructions (with overflow/underflow detection) - 32-bit shift instructions in 1 clock cycle - Bit manipulation instructions - Load/store instructions with long/short format - Signed load instructions 20 User's Manual U18743EE1V2UM00 User's Manual U18743EE1V2UM00 Serial interfaces 6 KB 96 KB `F3617 8 KB 128 KB 1 ch WDT2 2 ch 1 ch Watch 2 ch 1 ch 1 ch CSI IIC CAN UART/LIN 10 bits x 10 ch 1 ch TMM 67 10 bits x 12 ch typ. 8 MHz typ. 240 KHz operates on RC or crystal 5 ch 51 6 KB 64 KB TAA High speed internal oscillator A/D Converter Timers I/O ports `F3616 V850ES (32 bit RISC) `F3615 operates on 4 MHz to 16 MHz crystal 16 KB 256 KB `F3614 MainOSC 12 KB 192 KB `F3613 x8 8 KB 128 KB `F3612 PLL ratio 6 KB 96 KB `F3611 V850ES/FF3-L 20 MHz 6 KB 64 KB `F3610 V850ES/FE3-L V850ES/Fx3-L features (1/2) max. CPU frequency RAM Code Flash Operating SubOSC clock Low speed internal oscillator Internal memory CPU Product Series name Table 1-1 The following table gives an overview of the most outstanding controller features. 12 KB 192 KB `F3618 16 KB 256 KB `F3619 8 KB 128 KB `F3620 3 ch 10 bits x 16 ch 84 12 KB 192 KB `F3621 `F3622 16 KB 256 KB V850ES/FG3-L Introduction Chapter 1 21 22 User's Manual U18743EE1V2UM00 On-chip debug 80-pin QFP 3.3 V to 5.5 Va Yes Low-Voltage Detection typical below 3.7 V / 4.0 V (selectable by software)a LVI Yes `F3619 Power-On-Clear typical below 3.5 Va 64-pin QFP `F3618 POC Clock Monitor Refer to Electrical Target Specification Package a) `F3617 8 ch `F3616 Key return input `F3615 HALT, IDLE1, IDLE2, Sub_IDLE, STOP `F3614 Power save modes `F3613 39 ch `F3612 Internal `F3611 V850ES/FF3-L 9 ch `F3610 V850ES/FE3-L V850ES/Fx3-L features (2/2) External (incl. NMI) Operating voltage Other functions Interrupts Product Series name Table 1-1 `F3620 100-pin QFP 42 ch 12 ch `F3621 V850ES/FG3-L `F3622 Chapter 1 Introduction Introduction Chapter 1 1.3 Description The following figure provides a functional block diagram of the V850ES/FE3-L, V850ES/FF3-L, and V850ES/FG3-L microcontrollers. NMI INTP0 to INTP7 INTP8 to INTP11Note 1 Interrupt Controller Power and Reset Reset POC Low Voltage Detector Key Interrupt KR0 to KR7 Power supply CPU Memory Access Note 4 Code flash memory Serial Interfaces RXDD0 to RXDD1 TXDD0 to TXDD1 ASCKD0 CPU Core Note 5 UARTD0 to UARTD1 RXDD2 TXDD2 RAM BRG System Controller Note 1 UARTD2 Bus Control Unit BRG SIB0 to SIB1 SOB0 to SOB1 SCKB0 to SCKB1 Standby Controller CSIB0 to CSIB1 BRG SDA00 SCL00 IC CRXD0 CTXD0 CAN0 2 Bus Bridge Internal Bus Control Interfaces Note 6 Ports Note 2,3 Internal Timers 10-bit ADC 10/12/16 channels 16-bit Timer M P00 to P06 P10 tp P11 P30 to P39 P40 to P42 P50 to P55 P70 to 715 P90 to P915 PCM0 to PCM3 PCS0 to PCS1 PCT0,1,4,6 PDL0 to PDL13 ANI0 to ANI9 ANI10 to ANI11Note 2 ANI12 to ANI15Note 3 ADTRG AVREF0 AVSS Watch Timer Timers TIAA00 to TIAA40 TIAA01 to TIAA41 TOAA00 to TOAA40 TOAA01 to TOAA41 16-bit Timers TAA0 to TAA4 Watchdog Timer 2 Clock Generator Internal oscillator 240 KHz Internal oscillator 8 MHz Sub oscillator Auxiliary Functions On-chip debug unit Figure 1-1 DRST DDI DDO DCK DMS Main oscillator with PLL XT1 XT2 X1 X2 PCL CLKOUT Clock Monitor V850ES/FE3-L, V850ES/FF3-L, V850ES/FG3-L block diagram User's Manual U18743EE1V2UM00 23 Chapter 1 Introduction Table 1-2 on page 24 summarizes the different features of the V850ES/FE3-L, V850ES/FF3-L, V850ES/FG3-L series devices, marked as "Notes" in Figure 1-1 on page 23. Table 1-2 24 V850ES/FE3-L, V850ES/FF3-L, V850ES/FG3-L feature set differences V850ES/FE3-L V850ES/FF3-L V850ES/FG3-L INTP8,9,10, UARTD2 - - 2 ANI10 to ANI11 - 3 ANI12 to ANI15 - - 4 Code flash refer to "Memory" on page 151 5 RAM refer to "Memory" on page 151 6 Ports refer to "Pin Functions" on page 31 Note Feature 1 User's Manual U18743EE1V2UM00 Introduction Chapter 1 1.3.1 Internal units CPU The CPU can execute almost all instruction processing, such as address calculation, arithmetic and logic operations, and data transfer, in one clock under control of a five-stage pipeline. Dedicated hardware units such as a multiplier and a 32-bit barrel shifter are provided to speed up complicated instruction processing. Bus Control Unit The Bus Control Unit (BCU) and Memory Controller (MEMC) control the access to on-chip peripheral I/Os. ROM The ROM consists of an internal flash memory and consists of the code flash. For the available sizes, refer to Table 1-1 on page 21. RAM For the available RAM sizes, refer to Table 1-1 on page 21. Ports General-purpose port functions and control pin functions are available. Clock Generator The Clock Generator generates the system clocks. It has four independent oscillators to ensure system operability if the main oscillator should fail and to provide low-speed clocks in power-save modes. Clock Monitor The Clock Monitor monitors the main oscillator. In case of failure, it can switch the system to a different oscillator. On-chip Debug function Interrupt Controller Key Interrupt Function UARTD An on-chip debug function that uses the N-Wire interface is provided. The Interrupt Controller (INTC) processes non-maskable and maskable interrupt requests from the on-chip peripheral hardware and external sources. Eight levels of priorities can be specified for these interrupt requests, and multiple servicing control can be performed on interrupt sources. A key interrupt request signal can be generated by applying a falling edge to key input pins on eight channels. The UARTs provide 2-wire Asynchronous Serial Interfaces. CSIB The Clocked Serial Interfaces are 3-wire variable-length serial interfaces. CAN Controller The CAN Controller is a small-scale digital data transmission system that transfers data between units. A/D Converter Timers/counters Watch Timer Watchdog Timer 2 This is a high-speed, high-resolution 10-bit A/D Converter with 24 analog input pins. This converter is of successive approximation type. Five 16-bit timers/event counters TAA and one 16-bit interval timer TMM are provided. The Watch Timer (WT) output forms the reference for the bookkeeping of daytime and calendar. The Watchdog Timer (WDT2) is used to detect a program loop and system errors. When the Watchdog Timer overflows, it generates a non-maskable interrupt request signal or a system reset signal. 1.3.2 Structure of the manual This manual explains how to use the V850ES/Fx3-L microcontroller devices. It provides comprehensive information about the building blocks, their features, and how to set registers in order to enable or disable specific functions. The manual provides individual chapters for the building blocks. These chapters are organized according to the grouping in the diagram. User's Manual U18743EE1V2UM00 25 Chapter 1 Introduction * Core functions "Pin Functions" on page 31 "CPU System Functions" on page 135 "Clock Generator" on page 179 "Interrupt Controller (INTC)" on page 221 "Key Interrupt Function" on page 257 * Memory access "Flash Memory" on page 259 * Timers "16-Bit Timer/Event Counter AA" on page 305 "16-Bit Interval Timer M" on page 371 "Watch Timer Functions" on page 379 "Watchdog Timer 2" on page 385 * Serial interfaces "Asynchronous Serial Interface (UARTD)" on page 391 "Clocked Serial Interface (CSIB)" on page 427 "I2C Bus (IIC)" on page 457 "CAN Controller (CAN)" on page 527 * Control interfaces "A/D Converter (ADC)" on page 663 * Power and reset "Power Supply Scheme" on page 701 "Reset" on page 705 "Low-Voltage Detector" on page 713 * Auxiliary functions "On-Chip Debug Unit" on page 723 26 User's Manual U18743EE1V2UM00 Introduction Chapter 1 1.4 Ordering Information 1.4.1 V850ES/FE3-L ordering information Part number UPD70F3610M1GBA-GAH-AX UPD70F3610M1GBA1-GAH-AX Package 64-pin plastic LQFP (0.5mm, 10 x 10 mm2) On-chip flash memory 64 KB Quality gradea A A1 UPD70F3610M1GBA2-GAH-AX A2 UPD70F3610M2GBA-GAH-AX A UPD70F3610M2GBA1-GAH-AX A1 UPD70F3610M2GBA2-GAH-AX A2 UPD70F3610M1GAA-GAN-AX UPD70F3610M1GAA1-GAN-AX 64-pin plastic LQFP (0.4mm, 7x 7mm2) A A1 UPD70F3610M1GAA2-GAN-AX A2 UPD70F3610M2GAA-GAN-AX A UPD70F3610M2GAA1-GAN-AX A1 UPD70F3610M2GAA2-GAN-AX A2 UPD70F3611M1GBA-GAH-AX UPD70F3611M1GBA1-GAH-AX 64-pin plastic LQFP (0.5mm, 10 x 10 mm2) 96 KB A A1 UPD70F3611M1GBA2-GAH-AX A2 UPD70F3611M2GBA-GAH-AX A UPD70F3611M2GBA1-GAH-AX A1 UPD70F3611M2GBA2-GAH-AX A2 UPD70F3611M1GAA-GAN-AX UPD70F3611M1GAA1-GAN-AX 64-pin plastic LQFP (0.4mm, 7x 7mm2) A A1 UPD70F3611M1GAA2-GAN-AX A2 UPD70F3611M2GAA-GAN-AX A UPD70F3611M2GAA1-GAN-AX A1 UPD70F3611M2GAA2-GAN-AX A2 UPD70F3612M1GBA-GAH-AX UPD70F3612M1GBA1-GAH-AX 64-pin plastic LQFP (0.5mm, 10 x 10 mm2) 128 KB A A1 UPD70F3612M1GBA2-GAH-AX A2 UPD70F3612M2GBA-GAH-AX A UPD70F3612M2GBA1-GAH-AX A1 UPD70F3612M2GBA2-GAH-AX A2 UPD70F3612M1GAA-GAN-AX UPD70F3612M1GAA1-GAN-AX 64-pin plastic LQFP (0.4mm, 7x 7mm2) A A1 UPD70F3612M1GAA2-GAN-AX A2 UPD70F3612M2GAA-GAN-AX A UPD70F3612M2GAA1-GAN-AX A1 UPD70F3612M2GAA2-GAN-AX A2 User's Manual U18743EE1V2UM00 Remark without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit 27 Chapter 1 Introduction Part number UPD70F3613M1GBA-GAH-AX UPD70F3613M1GBA1-GAH-AX Package 64-pin plastic LQFP (0.5mm, 10 x 10 mm2) On-chip flash memory 192KB Quality gradea A A1 UPD70F3613M1GBA2-GAH-AX A2 UPD70F3613M2GBA-GAH-AX A UPD70F3613M2GBA1-GAH-AX A1 UPD70F3613M2GBA1-GAH-AX A1 UPD70F3614M1GBA-GAH-AX 256KB A UPD70F3614M1GBA1-GAH-AX A1 UPD70F3614M1GBA2-GAH-AX A2 UPD70F3614M2GBA-GAH-AX A UPD70F3614M2GBA1-GAH-AX A1 UPD70F3614M2GBA1-GAH-AX A1 a) 28 The operating ambient temperature of each quality grades is as follows: A: -40 to +85 C, A1: -40 to +110 C, A2: -40 to +125 C User's Manual U18743EE1V2UM00 Remark without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit Introduction Chapter 1 1.4.2 V850ES/FF3-L ordering information Part number UPD70F361M1GBA-GAH-AX UPD70F3615M1GBA1-GAH-AX Package 80-pin plastic LQFP (0.5mm, 12 x 12 mm2) On-chip flash memory 64 KB Quality gradea A A1 UPD70F3615M1GBA2-GAH-AX A2 UPD70F3615M2GBA-GAH-AX A UPD70F3615MGBA1-GAH-AX A1 UPD70F3615M2GBA2-GAH-AX A2 UPD70F3616M1GBA-GAH-AX 96 KB A UPD70F3616M1GBA1-GAH-AX A1 UPD70F3616M1GBA2-GAH-AX A2 UPD70F3616M2GBA-GAH-AX A UPD70F3616M2GBA1-GAH-AX A1 UPD70F3616M2GBA2-GAH-AX A2 UPD70F3617M1GBA-GAH-AX 128 KB A UPD70F3617M1GBA1-GAH-AX A1 UPD70F3617M1GBA2-GAH-AX A2 UPD70F3617M2GBA-GAH-AX A UPD70F3617M2GBA1-GAH-AX A1 UPD70F3617M2GBA2-GAH-AX A2 UPD70F3618M1GBA-GAH-AX 192KB A UPD70F3618M1GBA1-GAH-AX A1 UPD70F3618M1GBA2-GAH-AX A2 UPD70F3618M2GBA-GAH-AX A UPD70F3618M2GBA1-GAH-AX A1 UPD70F3618M2GBA1-GAH-AX A1 UPD70F3619M1GBA-GAH-AX 256KB A UPD70F3619M1GBA1-GAH-AX A1 UPD70F3619M1GBA2-GAH-AX A2 UPD70F3619M2GBA-GAH-AX A UPD70F3619M2GBA1-GAH-AX A1 UPD70F3619M2GBA1-GAH-AX A1 a) Remark without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit The operating ambient temperature of each quality grades is as follows: A: -40 to +85 C, A1: -40 to +110 C, A2: -40 to +125 C User's Manual U18743EE1V2UM00 29 Chapter 1 Introduction 1.4.3 V850ES/FG3-L ordering information Part number UPD70F3620M1GBA-GAH-AX UPD70F3620M1GBA1-GAH-AX Package 100-pin plastic LQFP (0.5mm, 14 x 14 mm2) On-chip flash memory 128 KB Quality gradea A A1 UPD70F3620M1GBA2-GAH-AX A2 UPD70F3620M2GBA-GAH-AX A UPD70F3620M2GBA1-GAH-AX A1 UPD70F3620M2GBA2-GAH-AX A2 UPD70F3621M1GBA-GAH-AX 192KB A UPD70F3621M1GBA1-GAH-AX A1 UPD70F3621M1GBA2-GAH-AX A2 UPD70F3621M2GBA-GAH-AX A UPD70F3621M2GBA1-GAH-AX A1 UPD70F3621M2GBA1-GAH-AX A1 UPD70F3622M1GBA-GAH-AX 256KB A UPD70F3622M1GBA1-GAH-AX A1 UPD70F3622M1GBA2-GAH-AX A2 UPD70F3622M2GBA-GAH-AX A UPD70F3622M2GBA1-GAH-AX A1 UPD70F3622M2GBA1-GAH-AX A1 a) 30 The operating ambient temperature of each quality grades is as follows: A: -40 to +85 C, A1: -40 to +110 C, A2: -40 to +125 C User's Manual U18743EE1V2UM00 Remark without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit without Power-OnClear circuit with Power-OnClear circuit Chapter 2 Pin Functions This chapter lists the ports of the microcontroller. It presents the configuration of the ports for alternative functions. Noise elimination on input signals is explained and a recommendation for the connection of unused pins is given at the end of the chapter. 2.1 Overview The microcontroller offers various pins for input/output functions, so-called ports. The ports are organized in port groups. To allocate other than general purpose input/output functions to the pins, several control registers are provided. For a description of the terms pin, port or port group, see "Terms" on page 35. Features summary * Number of ports and port groups: V850ES/FE3-L V850ES/FF3-L V850ES/FG3-L Port groups 8 10 11 I/O ports 51 67 84 * Configuration possible for individual pins. * For many pins, the connection of a pull-up resistor can be selected. User's Manual U18743EE1V2UM00 31 Chapter 2 Pin Functions 2.1.1 Description The V850ES/FE3-L, V850ES/FF3-L, and V850ES/FG3-L microcontrollers have the port groups shown below. P90 Port group 0 P00 P91 to P96 to P99 P06 Port group 1 P10 P11 P30 to P35 P36 Port group 3 P37 P38 P39 FG3-L only FG3-L only P913 to P915 P92 to P95 P910 to P912 Port group 9 FG3-L only PCM0 FF3-L/FG3-L only PCM1 Port group CM FF3-L/FG3-L only PCM2 FF3-L/FG3-L only PCS0 PCM3 P40 Port group 4 to P42 P50 Port group 5 to P55 PCS1 Port group CS PCT0 FF3-L/FG3-L only PCT1 PCT4 Port group CT PCT6 P70 to P79 Port group 7 Figure 2-1 32 PDL0 to PDL7 P710 FF3-L/FG3-L only P711 PDL8 FF3-L/FG3-L to only P712 PDL11 FG3-L to only P715 FG3-L PDL12 only PDL13 Port group DL V850ES/FE3-L, V850ES/FF3-L, V850ES/FG3-L port groups User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 Port group overview Table 2-1 gives an overview of the port groups. For each port group it shows the supported functions in port mode and in alternative mode. Any port group can operate in 8-bit or 1-bit units. Port groups 3, 6, 9 and DL can additionally operate in 16-bit units. Note Not all port groups and functions in Table 2-1 are available for all products of the V850ES/Fx3-L product line. For detailed information which port groups and functions are available for a dedicated product, refer to "2.4 Port Type Diagrams" . Table 2-1 Functions of each port group Port group name Pin configuration Function Port mode Alternative mode 0 7-bit input/output * * * * * * * External interrupt 0 to 3 Non-maskable interrupt N-Wire debug interface reset A/D Converter 0 external trigger input Timer TAA3 channels Timer TAA4 channels CAN0 transmit/receive data 1 2-bit input/output * External interrupt 9 and 10 3 10-bit input/output * * * * * * 4 3-bit input/output * Key interrupt input 0 to 2 * Clocked Serial Interface CSIB0 data/clock line 5 6-bit input/output * Key interrupt input 0 to 5 * N-Wire debug interface signals 7 16-bit input/output * A/D Converter 0 inputs 9 16-bit input/output * * * * * * * CM 6-bit input/output * CPU system clock output CS 8-bit input/output * CT 8-bit input/output * DL 16-bit input/output * External interrupt 7 and 8 Timer TAA0 channels Timer TAA1 channels CAN0 transmit/receive data UARTD0 transmit/receive data UARTD0 baud rate clock input External interrupt 4 to 6 Key interrupt input 6 to 7 Timer TAA2 channels Clocked Serial Interface CSIB1 data/clock line UARTD1 transmit/receive data I2C data/clock line Programmable clock output To define the function and the electrical characteristics of a pin, several control registers are provided. * For a general description of the registers, see "Port Group Configuration Registers" on page 36. * For every port, detailed information on the configuration registers is given in User's Manual U18743EE1V2UM00 33 Chapter 2 Pin Functions "Port Type Diagrams" on page 51. 34 User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.1.2 Terms In this section, the following terms are used: * Pin Denotes the physical pin. Every pin is uniquely denoted by its pin number. A pin can be used in several modes. Depending on the selected mode, a pin name is allocated to the pin. * Port group Denotes a group of pins. The pins of a port group have a common set of port mode control registers. * Port mode / Port A pin in port mode works as a general purpose input/output pin. It is then called "port". The corresponding name is Pnm. For example, P04 denotes port 4 of port group 0. It is referenced as "port P04". * Alternative mode In alternative mode, a pin can work in various non-general purpose input/ output functions, for example, as the input/output pin of on-chip peripherals. The corresponding pin name depends on the selected function. For example, pin INTP0 denotes the pin for one of the external interrupt inputs. Note that for example P03 and INTP0 denote the same physical pin. The different names indicate the function in which the pin is being operated. * Port type A control circuit evaluates the settings of the configuration registers. There are different types of control circuits, called "port types". 2.1.3 Noise elimination The input signals at some pins are passing a filter to remove noise and glitches. The microcontroller supports both analog and digital filters. See "Noise Elimination" on page 126 for a detailed description. User's Manual U18743EE1V2UM00 35 Chapter 2 Pin Functions 2.2 Port Group Configuration Registers This section starts with an overview of all configuration registers and then presents all registers in detail. The configuration registers are classified in the following groups: * "Pin function configuration" on page 37 * "Pin data input/output" on page 43 * "Configuration of pull-up resistors" on page 45 2.2.1 Overview For the configuration of the individual pins of the port groups, the following registers are used: Table 2-2 Registers for port group configuration Register name Shortcut Function Port mode control register PMCn Pin function configuration Port mode register PMn Port function control register PFCn Port function control expansion register PFCEn On-chip debug mode register OCDM Port register Pn Pin data input/output Pull-up resistor option register PUn Configuration of pull-up resistors Port function register PFn Open drain configuration n = 0, 1, 3 to 5, 7, 9 , CM, CS, CT, DL 36 User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.2.2 Pin function configuration The registers for pin function configuration define the general function of a pin: * port mode or alternative mode * in port mode: input mode or output mode * in alternative mode: selection of one of the alternative functions in alternative mode * normal mode or on-chip debug mode (N-Wire interface) An overview of the register settings is given in the table below. Table 2-3 Pin function configuration (overview) Registers Function OCDM Port mode (output) PMC 0 Port mode (input) Alternative mode (alternative function 1) Alternative mode (alternative function 2) PFCE PFC 0 X X O 1 X X I 0 0 1 Alternative mode (alternative function 3) X 1 Alternative mode (alternative function 4) On-chip debug a) b) modeb 1 X I/O PM X X 0 1 0 I/Oa 1 X I/O In alternative mode, the corresponding port type defines whether a pin is in input mode or output mode. In on-chip debug mode, the corresponding pins are automatically set as input or output pins to provide the N-Wire interface. In this mode, the configuration of these pins can not be changed by the pin configuration registers. User's Manual U18743EE1V2UM00 37 Chapter 2 Pin Functions (1) PMCn - Port mode control register The PMCn register specifies whether the individual pins of port group n are in port mode or in alternative mode. For port groups with up to eight ports, this is an 8-bit register. For port groups with up to 16 ports, this is a 16-bit register. Access Address Initial Value 15 14 13 12 This register can be read/written in 8-bit and 1-bit units. 16-bit registers can also be read/written in 16-bit units. see "Port Type Diagrams" on page 51 00H or 0000H. This register is initialized by any reset. 7 6 5 4 3 2 1 0 PMCn7 PMCn6 PMCn5 PMCn4 PMCn3 PMCn2 PMCn1 PMCn0 R/W R/W R/W R/W R/W R/W R/W R/W 10 9 4 3 11 8 7 6 5 2 1 0 PMCn15 PMCn14 PMCn13 PMCn12 PMCn11 PMCn10 PMCn9 PMCn8 PMCn7 PMCn6 PMCn5 PMCn4 PMCn3 PMCn2 PMCn1 PMCn0 R/W R/W R/W R/W Table 2-4 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W PMCn register contents Bit position 7 to 0 or 15 to 0 Caution R/W Bit name Function PMCn[7:0] Specifies the operation mode of the corresponding pin or 0: Port mode PMC[15:0] 1: Alternative mode When changing the function of a port from port mode (PCMnm = 0) to external interrupt input (PCMnm = 1) an advertent interrupt may occur. Therefore, it is recommended to follow the below procedure: 1. To select the alternative input function INTPn (I), set PFCE.PFCEnm and PFC.PFCnm accordingly. 2. Set PMCnm = 1 to change to the alternative mode. 3. Wait until the delay of the noise elimination filter has passed. 4. Set INTnIC.INTnIF = 0 to clear the interrupt request. 5. Clear INTnIC.INTnMK (or clear INTMR.INTnMK) to enable the interrupt. In step 3 you must wait for a certain time span because the external interrupt pins are equipped with noise elimination filters. The filters cause a delay in which the interrupt request flag INTnIC.INTnIF is set. This flag must be cleared (step 4). 38 User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 (2) PMn - Port mode register The PMn register specifies whether the individual pins of the port group n are in input mode or in output mode. For port groups with up to eight ports, this is an 8-bit register. For port groups with up to 16 ports, this is a 16-bit register. Note Access Address Initial Value 15 14 13 12 If a pin is in alternative mode (PMCn.PMCnm = 1) and the corresponding PMn bit is set (PMn.PMnm = 1), then the pin behaves as in input port mode: Reading Pn.Pmn reads the pin status. This register can be read/written in 8-bit and 1-bit units. 16-bit registers can also be read/written in 16-bit units. see "Port Type Diagrams" on page 51 FFH or FFFFH. This register is initialized by any reset. 7 6 5 4 3 2 1 0 PMn7 PMn6 PMn5 PMn4 PMn3 PMn2 PMn1 PMn0 R/W R/W R/W R/W R/W R/W R/W R/W 10 9 11 PMn15 PMn14 PMn13 PMn12 PMn11 PMn10 PMn9 R/W R/W R/W R/W Table 2-5 R/W R/W R/W 8 7 6 5 4 3 2 1 0 PMn8 PMn7 PMn6 PMn5 PMn4 PMn3 PMn2 PMn1 PMn0 R/W R/W R/W R/W R/W R/W R/W R/W R/W PMn register contents Bit position 7 to 0 or 15 to 0 Bit name Function PMn[7:0] Specifies input/output mode of the corresponding pin or 0: Output mode (output enabled) PMn[15:0] 1: Input mode (output disabled) User's Manual U18743EE1V2UM00 39 Chapter 2 Pin Functions (3) PFCn - Port function control register If a pin is in alternative mode (PMCn.PMCnm = 1) some pins offer up to four alternative functions. The PFCn register together with the PFCEn register specifies which function of a pin is to be used. The corresponding port type defines whether a pin is in input or output mode. Access This register can be read/written in 8-bit and 1-bit units. 16-bit registers can also be read/written in 16-bit units. Address see "Port Type Diagrams" on page 51 Initial Value 15 14 6 5 4 3 2 1 0 PFCn7 PFCn6 PFCn5 PFCn4 PFCn3 PFCn2 PFCn1 PFCn0 R/W R/W R/W R/W R/W R/W R/W R/W 10 9 7 6 5 4 3 2 1 0 PFCn15 PFCn14 PFCn13 PFCn12 PFCn11 PFCn10 PFCn9 PFCn8 PFCn7 PFCn6 PFCn5 PFCn4 PFCn3 PFCn2 PFCn1 PFCn0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W 12 7 8 R/W 13 00H. This register is initialized by any reset. R/W Table 2-6 11 R/W R/W PFCn register contents Bit position 40 R/W Bit name Function 7 to 0 PFCn[7:0] See "Pin function configuration (overview)" on page 37 for details 15 to 0 PFCn[15:0] See "Pin function configuration (overview)" on page 37 for details User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 (4) PFCEn - Port function control expansion register If a pin is in alternative mode (PMCn.PMCnm = 1) some pins offer up to four alternative functions. The PFCEn together with the PFCn register specifies which function of a pin is to be used. The corresponding port type defines whether a pin is in input or output mode. Access Address Initial Value This register can be read/written in 8-bit and 1-bit units. 16-bit registers can also be read/written in 16-bit units. see "Port Type Diagrams" on page 51 00H or 0000H. This register is initialized by any reset. 7 6 5 4 3 2 1 0 PFCEn7 PFCEn6 PFCEn5 PFCEn4 PFCEn3 PFCEn2 PFCEn1 PFCEn0 R/W 15 14 13 12 11 R/W R/W 10 9 R/W 8 R/W 7 R/W 6 5 R/W R/W 4 3 2 1 0 PFCEn15 PFCEn14 PFCEn13 PFCEn12 PFCEn11 PFCEn10 PFCEn9 PFCEn8 PFCEn7 PFCEn6 PFCEn5 PFCEn4 PFCEn3 PFCEn2 PFCEn1 PFCEn0 R/W R/W R/W R/W Table 2-7 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W PFCEn register contents Bit position Bit name Function 7 to 0 PFCEn[7:0] See "Pin function configuration (overview)" on page 37 for details 15 to 0 PFCEn[15:0] See "Pin function configuration (overview)" on page 37 for details User's Manual U18743EE1V2UM00 41 Chapter 2 Pin Functions (5) OCDM - On-chip debug mode register The 8-bit OCDM register specifies whether dedicated pins of the microcontroller operate in normal operation mode or can be used for on-chip debugging (N-Wire interface). The setting of this register concerns only those pins that can be used for the N-Wire interface: P05/DRST, P52/DDI, P53/DDO, P54/DCK, and P55/DMS. To make these pins available for on-chip debugging, bit OCDM.OCDM0 must be set while pin DRST is high. If the on-chip debug mode is selected, the corresponding pins are automatically set as input or output pins, respectively. Setting of bits PMn.PMnm is not necessary. For more details refer to "On-Chip Debug Unit" on page 723. Writing to this register is protected by a special sequence of instructions. Please refer to "CPU System Functions" on page 135 for details. Access Address Initial Value This register can be read/written in 8-bit and 1-bit units. The register can only be written if a low level ('0') is input to the P05/DRST pin. FFFF F9FCH 00H/01H: * After Power-On-Clear reset, the normal operation mode is selected (OCDM.OCDM0 = 0). * After external RESET, the dedicated pins are available for on-chip debugging (OCDM.OCDM0 = 1). * After any other reset, bit OCDM0 holds the same value as before the reset. 7 Table 2-8 6 5 4 3 2 1 0 0 0 0 0 0 0 0 OCDM0 R R R R R R R R/W OCDM register contents Bit position 0 Bit name OCDM0 Function Enables/disables N-Wire interface: 0: Pins are used in normal operation mode (port mode or alternative mode). DRST pull-down resistor not connected 1: Pins are used in on-chip debug mode. DRST pull-down resistor connected Note If the pins P05/DRST, P52/DDI, P53/DDO, P54/DCK, and P55/DMS are used as N-Wire interface pins their configuration can not be changed by the pin configuration registers. DRST pull-down resistor DRST (P05) is equipped with an internal pull-down resistor. Connection of the resistor is controlled by OCDM.OCDM0: 0: resistor detached from P05/DRST 1: resistor attached to P05/DRST This ensures that the microcontroller is operating correctly, even if the pins are in N-Wire mode, but no debugger is connected. 42 User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.2.3 Pin data input/output If a pin is in port mode, the registers for pin data input/output specify the input and output data. (1) Pn - Port register If a pin is in port mode (PMCn.PMCnm = 0), data is input from or output to an external device by writing or reading the Pn register. For port groups with up to eight ports, this is an 8-bit register. For port groups with up to 16 ports, this is a 16-bit register. Access Address Initial Value Note 15 14 13 see "Port Type Diagrams" on page 51 Undefined. After reset, the ports are in input mode (PMn.PMnm = 1). The read input value is determined by the port pins. 7 6 5 4 3 2 1 0 Pn7 Pn6 Pn5 Pn4 Pn3 Pn2 Pn1 Pn0 R/W R/W R/W R/W R/W R/W R/W R/W 9 8 7 6 5 4 3 2 1 0 Pn15 Pn14 Pn13 Pn12 Pn11 Pn10 Pn9 Pn8 Pn7 Pn6 Pn5 Pn4 Pn3 Pn2 Pn1 Pn0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W 12 This register can be read/written in 8-bit and 1-bit units. 16-bit registers can also be read/written in 16-bit units. R/W R/W Table 2-9 11 R/W 10 R/W Pn register contents Bit position Bit name 7 to 0 or 15 to 0 Note Pn[7:0] or Pn[15:0] Function Data, see Table 2-10 on page 43 and Table 2-11 on page 44 for details. The value written to register Pn is retained until a new value is written to register Pn. Port mode In port mode (PMCn.PMCnm = 0), register PMn specifies whether a pin is in input or in output mode. Data is written to or read from the Pn register as follows: Table 2-10 Writing/reading register Pn in port mode (PMCn.PMCnm = 0) Function PM I/O ...and output contents of Pn to pins 0 O ...without affecting the pin status 1 I ...and thus read the pin status 1 I ...and disregard the pin status 0 O Write to Pn... Read from Pn... User's Manual U18743EE1V2UM00 43 Chapter 2 Pin Functions Alternative mode In alternative mode (PMCn.PMCnm = 1), the corresponding port type defines whether a pin is in input or output mode. However, register PMn influences the writing/reading of register Pn. In alternative mode, data is written to or read from the Pn register as follows: Table 2-11 Writing/reading register Pn in alternative mode (PMCn.PMCnm = 1) Function Write to Pn without affecting the pin status PM I/O X - 0 - 1 I Read from Pn... ...and read the value of the alternative output function (for pins in alternative output function) ...and disregard the pin status (for pins in alternative input function) ...and thus read the pin status Caution Although 1-bit operations (read-modify-write operations) on Pn registers are intended to modify only a single bit, the entire Pn register is read. After the single bit has been modified, the contents of the complete register is written back. If the ports of the register Pn contain both input and output ports Pnm, the read of Pn returns * the contents of the register Pn for output ports * the pin status of input ports, but not the Pn register bits That means the read value of Pn may be different to the contents of the Pn register at bit positions, which are assigned to input ports. Thus the contents of Pn may differ to the previous value not just in the bit that was to be modified, but also in other bits. Example: * Register P1 has the contents 00H. * Port P10 is configured as an output port, all other ports of port group 1 (ports P11 to P17) are configured as input ports. * The port pins of ports P11 to P17 all have the level "1". * Bit P1.P10 is set to 1 by a 1-bit operation. Afterwards, register P1 holds the value FFH instead of the expected value 01H, since bits P11 to P17 have be overwritten with the corresponding pin levels "1". 44 User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.2.4 Configuration of pull-up resistors (1) PUn - Port pull-up resistor option register The PUn register specifies whether a pull-up resistor is connected to the pin. Access Address Initial Value 15 14 13 see "Port Type Diagrams" on page 51 00H or 0000H.. This register is cleared by any reset. 7 6 5 4 3 2 1 0 PUn7 PUn6 PUn5 PUn4 PUn3 PUn2 PUn1 PUn0 R/W R/W R/W R/W R/W R/W R/W R/W 10 9 8 7 6 5 4 3 2 1 0 PUn15 PUn14 PUn13 PUn12 PUn11 PUn10 PUn9 PUn8 PUn7 PUn6 PUn5 PUn4 PUn3 PUn2 PUn1 PUn0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W 12 This register can be read/written in 8-bit and 1-bit units. 16-bit registers can also be read/written in 16-bit units. R/W Table 2-12 11 R/W R/W PUn register contents Bit position 7 to 0 or 15 to 0 Caution R/W Bit name PUn[7:0] or PUn[15:0] Function Specifies whether a pull-up resistor is connected to the corresponding pin: 0: no pull-up resistor connected 1: pull-up resistor connected In Port mode, (PMCnm bit = 0), the PUnm bit of the PUn register is valid only when PMnm bit of PMn register is 0 (output mode). If PMnm bit = 1 (input mode), the setting value of PUn register is invalid (pull-up resistor is detached). User's Manual U18743EE1V2UM00 45 Chapter 2 Pin Functions 2.2.5 Open drain configuration (1) PFn - Port function register If a pin is in alternative mode (PMCn.PMCnm = 1), the PFn register specifies normal output or open-drain output. For port groups with up to eight ports, this is an 8-bit register. For port groups with up to 16 ports, this is a 16-bit register. Note Access Address Initial Value 15 14 13 This register can be read/written in 8-bit and 1-bit units. 16-bit registers can also be read/written in 16-bit units. see "Port Type Diagrams" on page 51 00FH or 0000H. This register is initialized by any reset. 7 6 5 4 3 2 1 0 PFn7 PFn6 PFn5 PFn4 PFn3 PFn2 PFn1 PFn0 R/W R/W R/W R/W R/W R/W R/W R/W 9 8 7 6 5 4 3 2 1 0 PFn15 PFn14 PFn13 PFn12 PFn11 PFn10 PFn9 PFn8 PFn7 PFn6 PFn5 PFn4 PFn3 PFn2 PFn1 PFn0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W 12 The settings of PFn are only valid in alternative mode. R/W Table 2-13 46 11 R/W 10 R/W PFn register contents Bit position Bit name 7 to 0 or 15 to 0 PFn[7:0] or PFn[15:0] Function Specifies normal output or open-drain output 0: Normal output 1: Open-drain output User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.3 Port Buffers Diagrams This chapter presents the block diagrams of all buffer types. The tables in "Port group configuration lists" on page 100 informs also about the buffer type, used for each port. (1) Buffer type 2 IN Figure 2-2 (2) Figure 2-3 Block diagram: buffer type 2 Buffer type 5 Block diagram: buffer type 5 User's Manual U18743EE1V2UM00 47 Chapter 2 Pin Functions (3) Figure 2-4 (4) Figure 2-5 48 Buffer type 5-AF Block diagram: buffer type 5-AF Buffer type 5-K Block diagram: buffer type 5-K User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 (5) Figure 2-6 (6) Figure 2-7 Buffer type 5-W Block diagram: buffer type 5-W Buffer type 11-G Block diagram: buffer type 11-G User's Manual U18743EE1V2UM00 49 Chapter 2 Pin Functions (7) Figure 2-8 50 Buffer type 16 Block diagram: buffer type 16 User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.4 Port Type Diagrams This chapter presents the block diagrams of all port types. The tables in the detailed descriptions of each port group from "Port group 0" on page 108 onwards informs also about the port type, used for each port. 2.4.1 Port type C WRPM (a) Output buffer control Pmn Selector Pmn Selector Internal bus PMmn WRPORT Address (b) Input buffer control RD Figure 2-9 Note Port type C block diagram For V850ES/FE3-L, V850ES/FF3-L, V850ES/FG3-L products the input buffer has Schmitt trigger (40/80%) characteristic User's Manual U18743EE1V2UM00 51 Chapter 2 Pin Functions 2.4.2 Port type C-U EVDD WRPU PUmn (c) Pull-up control Pch Internal bus WRPM (a) Output buffer control PMmn WRPORT Pmn Selector Selector Pmn Address RD Figure 2-10 52 Port type C-U block diagram User's Manual U18743EE1V2UM00 (b) Input buffer control Pin Functions Chapter 2 2.4.3 Port type D0 WRPMC PMCmn WRPM (a) Output buffer control Internal bus PMmn 1st alternate function WRPORT (d) Output data Selection Pmn Selector Selector Pmn Address (b) Input buffer control RD Figure 2-11 Port type D0 block diagram User's Manual U18743EE1V2UM00 53 Chapter 2 Pin Functions 2.4.4 Port type D0-U EVDD WRPU PUmn (c) Pull-up control WRPMC Pch PMCmn WRPM (a) Output buffer control Internal bus PMmn 1st alternate function WRPORT (d) Output data Selection Selector Selector Pmn Address RD Figure 2-12 54 Port type D0-U block diagram User's Manual U18743EE1V2UM00 (b) Input buffer control Pmn Pin Functions Chapter 2 2.4.5 Port type D1 WR PMC PMCmn WR PM WR PORT Pmn Selector Pmn Selector Internal bus (a) Output buffer control PMmn Address (b) Input buffer control (e) Alternate function input RD 1st alternate f unction Figure 2-13 control Port type D1 block diagram User's Manual U18743EE1V2UM00 55 Chapter 2 Pin Functions 2.4.6 Port type D1-U EVDD WR PU PUmn (c) Pull-up control WR PMC Pch PMCmn Internal bus WR PM (a) Output buffer control PMmn WR PORT Pmn Selector Selector Pmn Address (b) Input buffer control (e) Alternate function input RD 1st alternate f unction Figure 2-14 56 Port type D1-U block diagram User's Manual U18743EE1V2UM00 control Pin Functions Chapter 2 2.4.7 Port type D1-UI EVDD WR PU PUmn (c) Pull-up control WR INTR Pch INTRmn WR INTF INTFmn Internal bus WR PMC PMCmn WR PM (a) Output buffer control PMmn WR PORT Pmn Selector Selector Pmn Address (b) Input buffer control RD 1st alternate f unction Figure 2-15 Edge Noise detector remov al (e) Alternate function input control Port type D1-UI block diagram User's Manual U18743EE1V2UM00 57 Chapter 2 Pin Functions 2.4.8 Port type D3-UI EVDD WR PU PUmn (c) Pull-up control WR INTR Pch INTRmn WR INTF INTFmn Internal bus WR PMC PMCmn WR PM (a) Output buffer control PMmn WR PORT Pmn Selector Selector Pmn Address (b) Input buffer control RD 1st alternate f unction (INTPx) Edge Noise detector remov al (e) Alternate function input 1st alternate f unction (RXDDy ) Figure 2-16 58 Port type D3-UI block diagram User's Manual U18743EE1V2UM00 control Pin Functions Chapter 2 2.4.9 Port type D1A WRPMC PMCmn WRPM WRPORT Pmn Selector Pmn Selector Internal bus (a) Output buffer control PMmn Address (b) Input buffer control RD Pch 1st alternate function Nch Figure 2-17 Port type D1A block diagram User's Manual U18743EE1V2UM00 59 Chapter 2 Pin Functions 2.4.10 Port type D1O1-UI EVDD WR PU PUmn (c) Pull-up control WR INTR Pch INTRmn WR INTF INTFmn Internal bus WR OCDM OCDM0 WR PMC PMCmn WR PM (a) Output buffer control PMmn WR PORT Pmn Selector Selector Pmn Address (b) Input buffer control RD 1st alternate f unction _DRST signal (On-chip debug mode) Edge Noise detector remov al (e) Alternate function input control (f) On-chip debug input control POCRES Figure 2-18 60 Port type D1O1-UI block diagram User's Manual U18743EE1V2UM00 (g) Pull-down c ontr ol Nch Pin Functions Chapter 2 2.4.11 Port type D2 WR PMC Output enable signal 1 in alternative mode PMCmn WR PM (a) Output buffer control Internal bus PMmn 1st alternate f unction WR PORT (d) Output data Selection Pmn Selector Selector Pmn Address RD Input enable signal 1 in alternative mode 1st alternate f unction Figure 2-19 (b) Input buffer control (e) Alternate function input control Port type D2 block diagram User's Manual U18743EE1V2UM00 61 Chapter 2 Pin Functions 2.4.12 Port type E01-U EVDD WR PU PUmn (c) Pull-up control WR PFC Pch PFCmn WR PMC PMCmn Internal bus WR PM (a) Output buffer control PMmn 1st alternate f unction WR PORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control (e) Alternate function input RD 2nd alternate f unction Figure 2-20 62 Port type E01-U block diagram User's Manual U18743EE1V2UM00 control Pmn Pin Functions Chapter 2 2.4.13 Port type E10-U EVDD WR PU PUmn (c) Pull-up control WR PFC Pch PFCmn WR PMC PMCmn Internal bus WR PM (a) Output buffer control PMmn 2nd alternate f unction WR PORT (d) Output data Selection Pmn Selector Selector Pmn Address (b) Input buffer control (e) Alternate function input RD 1st alternate f unction Figure 2-21 control Port type E10-U block diagram User's Manual U18743EE1V2UM00 63 Chapter 2 Pin Functions 2.4.14 Port type E10-UI EVDD WR PU PUmn (c) Pull-up control WR INTR Pch INTRmn WR INTF INTFmn WR PFC PFCmn Internal bus WR PMC PMCmn WR PM (a) Output buffer control PMmn 2nd alternate f unction WR PORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD 1st alternate f unction Figure 2-22 64 Edge Noise detector remov al (e) Alternate function input Port type E10-UI block diagram User's Manual U18743EE1V2UM00 control Pmn Pin Functions Chapter 2 2.4.15 Port type E11-U EVDD WRPU PUmn (c) Pull-up control WRPFC Pch PFCmn PMCmn WRPM (a) Output buffer control PMmn WRPORT Pmn Selector Pmn Selector Internal bus WRPMC Address (b) Input buffer control RD 1st alternate function (e) Alternate function input control 2nd alternate function Figure 2-23 Port type E11-U block diagram User's Manual U18743EE1V2UM00 65 Chapter 2 Pin Functions 2.4.16 Port type E11-UI EVDD WRPU PUmn (c) Pull-up control WRINTR Pch INTRmn WRINTF INTFmn Internal bus WRPFC PFCmn WRPMC PMCmn WRPM (a) Output buffer control PMmn WRPORT Pmn Selector Selector Pmn Address (b) Input buffer control RD 1st alternate function Edge Noise (e) Alternate function input detector removal control 2nd alternate function Figure 2-24 66 Port type E11-UI block diagram User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.4.17 Port type E21-U EVDD WRPU PUmn WRPFC (c) Pull-up control Output enable signal 1 in alternative mode Pch PFCmn WRPMC (a) Output buffer control PMmn 1st alternate function WRPORT (d) Output data Selection Pmn Selector Pmn Selector Internal bus PMCmn WRPM Address (b) Input buffer control RD (e) Alternate function input 1st alternate function control 2nd alternate function Figure 2-25 Port type E21-U block diagram User's Manual U18743EE1V2UM00 67 Chapter 2 Pin Functions 2.4.18 Port type Ex0-U EVDD WRPU PUmn (c) Pull-up control WRPFC Pch PFCmn WRPMC PMCmn Internal bus WRPM (a) Output buffer control PMmn 2nd alternate function WRPORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD Figure 2-26 68 Port type Ex0-U block diagram User's Manual U18743EE1V2UM00 Pmn Pin Functions Chapter 2 2.4.19 Port type Ex1-U EVDD WR PU PUmn (c) Pull-up control WR PFC Pch PFCmn PMCmn WR PM (a) Output buffer control PMmn WR PORT Pmn Selector Pmn Selector Internal bus WR PMC Address (b) Input buffer control (e) Alternate function input RD 2nd alternate f unction Figure 2-27 control Port type Ex1-U block diagram User's Manual U18743EE1V2UM00 69 Chapter 2 Pin Functions 2.4.20 Port type Ex1-UI EVDD WR PU PUmn (c) Pull-up control WR INTR Pch INTRmn WR INTF INTFmn Internal bus WR PFC PFCmn WR PMC PMCmn WR PM (a) Output buffer control PMmn WR PORT Pmn Selector Selector Pmn Address (b) Input buffer control RD 2nd alternate f unction Figure 2-28 70 Edge Noise detector remov al (e) Alternate function input Port type Ex1-UI block diagram User's Manual U18743EE1V2UM00 control Pin Functions Chapter 2 2.4.21 Port type Ex2-U EVDD WR PU PUmn WR PFC (c) Pull- up control Pch Output enable signal 2 in alternative mode PFCmn WR PMC (a) Output buffer control PMmn 2nd alternate f unction WR PORT (d) Output data Selection Pmn Selector Pmn Selector Internal bus PMCmn WR PM Address (b) Input buffer control RD (e) Alternate function input 2nd alternate f unction Figure 2-29 control Port type Ex2-U block diagram User's Manual U18743EE1V2UM00 71 Chapter 2 Pin Functions 2.4.22 Port type F010x-U EVDD WR PU PUmn (c) Pull-up control WR PFCE Pch PFCEmn WR PFC PFCmn WR PMC Internal bus PMCmn WR PM (a) Output buffer control PMmn 1st alternate f unction 3rd alternate f unction (d) Output data Selection WR PORT Selector Selector Pmn Address (b) Input buffer control RD (e) Alternate function input 2nd alternate f unction Figure 2-30 72 Port type F010x-U block diagram User's Manual U18743EE1V2UM00 control Pmn Pin Functions Chapter 2 2.4.23 Port type F010x-UI EVDD WR PU PUmn (c) Pull-up control WR PFCE Pch PFCEmn WR PFC PFCmn WR PMC (a) Output buffer control PMmn 1st alternate f unction 3rd alternate f unction (d) Output data Selection WR PORT Pmn Selector Pmn Selector Internal bus PMCmn WR PM Address (b) Input buffer control RD (e) Alternate function input 2nd alternate f unction Figure 2-31 control Port type F010x-UI block diagram User's Manual U18743EE1V2UM00 73 Chapter 2 Pin Functions 2.4.24 Port type F100x-U EVDD WR PU PUmn (c) Pull-up control WR PFCE Pch PFCEmn WR PFC PFCmn WR PMC Internal bus PMCmn WR PM (a) Output buffer control PMmn 2nd alternate f unction 3rd alternate f unction (d) Output data Selection WR PORT Selector Selector Pmn Address (b) Input buffer control RD (e) Alternate function input 1st alternate f unction Figure 2-32 74 Port type F100x-U block diagram User's Manual U18743EE1V2UM00 control Pmn Pin Functions Chapter 2 2.4.25 Port type F1010-U EVDD WRPU PUmn (c) Pull-up control WRPFCE Pch PFCEmn WRPFC PFCmn WRPMC (a) Output buffer control PMmn 2nd alternate function 4th alternate function (d) Output data Selection WRPORT Pmn Selector Pmn Selector Internal bus PMCmn WRPM Address (b) Input buffer control RD (e) Alternate function input 1st alternate function control 3rd alternate function Figure 2-33 Port type F1010-U block diagram User's Manual U18743EE1V2UM00 75 Chapter 2 Pin Functions 2.4.26 Port type F101x-U EVDD WR PU PUmn (c) Pull-up control WR PFCE Pch PFCEmn WR PFC PFCmn WR PMC Internal bus PMCmn WR PM (a) Output buffer control PMmn 2nd alternate f unction WR PORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD (e) Alternate function input 1st alternate f unction 3rd alternate f unction Figure 2-34 76 Port type F101x-U block diagram User's Manual U18743EE1V2UM00 control Pmn Pin Functions Chapter 2 2.4.27 Port type F1100O0-U EVDD WRPU PUmn (c) Pull-up control Pch OCDM signal WRPFCE PFCEmn WRPFC PFCmn WRPMC (a) Output buffer control PMmn 3rd alternate function 4th alternate function On-chip debug function (d) Output data Selection WRPORT Pmn Selector Pmn Selector Internal bus PMCmn WRPM Address (b) Input buffer control RD (e) Alternate function input 1st alternate function control 2nd alternate function Figure 2-35 Port type F1100O0-U block diagram User's Manual U18743EE1V2UM00 77 Chapter 2 Pin Functions 2.4.28 Port type F1100O1-U EVDD WRPU PUmn (c) Pull-up control Pch OCDM signal WRPFCE PFCEmn WRPFC PFCmn WRPMC Internal bus PMCmn WRPM (a) Output buffer control PMmn 3rd alternate function 4th alternate function (d) Output data Selection WRPORT Selector Selector Pmn Address (b) Input buffer control RD 1st alternate function (e) Alternate function input control 2nd alternate function On-chip debug function Figure 2-36 78 Port type F1100O1-U block diagram User's Manual U18743EE1V2UM00 Pmn Pin Functions Chapter 2 2.4.29 Port type F1100-U EVDD WRPU PUmn (c) Pull-up control WRPFCE Pch PFCEmn WRPFC PFCmn WRPMC (a) Output buffer control PMmn 3rd alternate function 4th alternate function (d) Output data Selection WRPORT Pmn Selector Pmn Selector Internal bus PMCmn WRPM Address (b) Input buffer control RD (e) 1st alternate function input 1st alternate function control 2nd alternate function Figure 2-37 Port type F1100-U block diagram User's Manual U18743EE1V2UM00 79 Chapter 2 Pin Functions 2.4.30 Port type F1110-UI EVDD WRPU PUmn (c) Pull-up control WRINTR Pch INTRmn WRINTF INTFmn WRPFCE PFCEmn WRPFC Internal bus PFCmn WRPMC PMCmn WRPM (a) Output buffer control PMmn 4th alternate function WRPORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD 1st alternate function Edge Noise detector removal (e) Alternate function input 2nd alternate function 3rd alternate function Figure 2-38 80 Port type F1110-UI block diagram User's Manual U18743EE1V2UM00 control Pmn Pin Functions Chapter 2 2.4.31 Port type F113x-UI EVDD WRPU PUmn (c) Pull-up control WRINTR Pch INTRmn WRINTF INTFmn WRPFCE Internal bus PFCEmn WRPFC PFCmn WRPMC PMCmn WRPM (a) Output buffer control PMmn WRPORT Pmn Selector Selector Pmn Address (b) Input buffer control RD 1st alternate function (e) Alternate function input 2nd alternate function control 3rd alternate function (INTPx) Edge Noise detector removal 3rd alternate function (RXDDy) Figure 2-39 Port type F113x-UI block diagram User's Manual U18743EE1V2UM00 81 Chapter 2 Pin Functions 2.4.32 Port type F1x10-UI EVDD WR PU PUmn (c) Pull-up control WR INTR Pch INTRmn WR INTF INTFmn WR PFCE PFCEmn WR PFC Internal bus PFCmn WR PMC PMCmn WR PM (a) Output buffer control PMmn 4th alternate f unction WR PORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD 1st alternate f unction Edge Noise (e) Alternate function input detector remov al control 3rd alternate f unction Figure 2-40 82 Port type F1x10-UI block diagram User's Manual U18743EE1V2UM00 Pmn Pin Functions Chapter 2 2.4.33 Port type F3x1x-UI EVDD WR PU PUmn (c) Pull-up control WR INTR Pch INTRmn WR INTF INTFmn WR PFCE PFCEmn Internal bus WR PFC PFCmn WR PMC PMCmn WR PM (a) Output buffer control PMmn WR PORT Pmn Selector Selector Pmn Address (b) Input buffer control RD 1st alternate f unction (INTPx) Edge Noise detector remov al (e) Alternate function input control 1st alternate f unction (RXDDy ) 3rd alternate f unction Figure 2-41 Port type F1x1x-UI block diagram User's Manual U18743EE1V2UM00 83 Chapter 2 Pin Functions 2.4.34 Port type F1xx0O1-U EVDD WRPU PUmn (c) Pull-up control Pch OCDM signal WRPFCE PFCEmn WRPFC PFCmn Internal bus WRPMC PMCmn WRPM (a) Output buffer control PMmn 4th alternate function WRPORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD (e) Alternate function input 1st alternate function control On-chip debug function Figure 2-42 84 Port type F1xx0O1-U block diagram User's Manual U18743EE1V2UM00 Pmn Pin Functions Chapter 2 2.4.35 Port type Fx010-U EVDD WR PU PUmn (c) Pull-up control WR PFCE Pch PFCEmn WR PFC PFCmn WR PMC (a) Output buffer control PMmn 2nd alternate f unction 4th alternate f unction (d) Output data Selection WR PORT Pmn Selector Pmn Selector Internal bus PMCmn WR PM Address (b) Input buffer control RD (e) Alternate function input 3rd alternate f unction Figure 2-43 control Port type Fx010-U block diagram User's Manual U18743EE1V2UM00 85 Chapter 2 Pin Functions 2.4.36 Port type Fx01x-U EVDD WR PU PUmn (c) Pull- up control WR PFCE Pch PFCEmn WR PFC PFCmn WR PMC Internal bus PMCmn WR PM (a) Output buffer control PMmn 2nd alternate f unction WR PORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD (e) Alternate function input 3rd alternate f unction Figure 2-44 86 Port type Fx01x-U block diagram User's Manual U18743EE1V2UM00 control Pmn Pin Functions Chapter 2 2.4.37 Port type Fx103-UI EVDD WRPU PUmn (c) Pull-up control WRINTR Pch INTRmn WRINTF INTFmn WRPFCE PFCEmn WRPFC Internal bus PFCmn WRPMC PMCmn WRPM (a) Output buffer control PMmn 3rd alternate function WRPORT (d) Output data Selection Pmn Selector Selector Pmn Address (b) Input buffer control RD 2nd & 4th alternate function (INTPx) Edge Noise Share detector removal control (e) Alternate function input control 4th alternate function (RXDDy) Figure 2-45 Port type Fx103-UI block diagram User's Manual U18743EE1V2UM00 87 Chapter 2 Pin Functions 2.4.38 Port type Fx10x-U EVDD WR PU PUmn (c) Pull- up control WR PFCE Pch PFCEmn WR PFC PFCmn WR PMC Internal bus PMCmn WR PM (a) Output buffer control PMmn 2nd alternate f unction WR PORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD (e) Alternate function input 3rd alternate f unction Figure 2-46 88 Port type Fx10x-U block diagram User's Manual U18743EE1V2UM00 control Pmn Pin Functions Chapter 2 2.4.39 Port type Fx10x-UI EVDD WR PU PUmn (c) Pull-up control WR INTR Pch INTRmn WR INTF INTFmn WR PFCE PFCEmn WR PFC Internal bus PFCmn WR PMC PMCmn WR PM (a) Output buffer control PMmn 3rd alternate f unction WR PORT (d) Output data Selection Pmn Selector Selector Pmn Address (b) Input buffer control RD 2nd alternate f unction Figure 2-47 (e) Alternate function input Edge Noise detector remov al control Port type Fx10x-UI block diagram User's Manual U18743EE1V2UM00 89 Chapter 2 Pin Functions 2.4.40 Port type Fx110-U EVDD WR PU PUmn (c) Pull-up control WR PFCE Pch PFCEmn WR PFC PFCmn WR PMC Internal bus PMCmn WR PM (a) Output buffer control PMmn 4th alternate f unction WR PORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD (e) Alternate function input 2nd alternate f unction 3rd alternate f unction Figure 2-48 90 Port type Fx110-U block diagram User's Manual U18743EE1V2UM00 control Pmn Pin Functions Chapter 2 2.4.41 Port type Fx120-UFI EVDD WR PU PUmn (c) Pull-up control WR INTR Pch INTRmn WR INTF INTFmn WR PF PFmn WR PFCE PFCEmn Internal bus WR PFC PFCmn WR PMC PMCmn WR PM (a) Output buffer control PMmn 3rd alternate f unction 4th alternate f unction (d) Output data Selection WR PORT Pmn Selector Selector Pmn Address (b) Input buffer control RD 2nd alternate f unction Edge Noise (e) Alternate function input detector remov al control 3rd alternate f unction Figure 2-49 Port type Fx120-UFI block diagram User's Manual U18743EE1V2UM00 91 Chapter 2 Pin Functions 2.4.42 Port type Fx123-UFI EVDD WRPU PUmn (c) Pull-up control WRINTR Pch INTRmn WRINTF INTFmn WRPF PFmn WRPFCE PFCEmn Internal bus WRPFC PFCmn WRPMC PMCmn WRPM (a) Output buffer control PMmn 3rd alternate function WRPORT (d) Output data Selection Selector Selector Pmn Address (b) Input buffer control RD 2nd & 4th alternate function (INTPx) Edge Noise Share (e) Alternate function input detector removal control control 3rd alternate function 4th alternate function (RXDDy) Figure 2-50 92 Port type Fx123-UFI block diagram User's Manual U18743EE1V2UM00 Pmn Pin Functions Chapter 2 2.4.43 Port type Fx12x-UFI EVDD WRPU PUmn (c) Pull-up control WRINTR Pch INTRmn WRINTF INTFmn WRPF PFmn WRPFCE PFCEmn Internal bus WRPFC PFCmn WRPMC PMCmn WRPM (a) Output buffer control PMmn 3rd alternate function WRPORT (d) Output data Selection Pmn Selector Selector Pmn Address (b) Input buffer control RD 2nd alternate function Edge Noise (e) Alternate function input detector removal control 3rd alternate function Figure 2-51 Port type Fx12x-UFI block diagram User's Manual U18743EE1V2UM00 93 Chapter 2 Pin Functions 2.4.44 Port type Fx13x-U EVDD WRPU PUmn (c) Pull-up control WRPFCE Pch PFCEmn WRPFC Internal bus PFCmn WRPMC PMCmn WRPM (a) Output buffer control PMmn WRPORT Pmn Selector Selector Pmn Address (b) Input buffer control RD 2nd & 3rd alternate function (KRx) Share (e) Alternate function input control 3rd alternate function (RXDDy) Figure 2-52 94 Port type Fx13x-U block diagram User's Manual U18743EE1V2UM00 control Pin Functions Chapter 2 2.4.45 Port type Fx210-U EVDD WRPU PUmn WRPFCE (c) Pull-up control Output enable signale 2 in alternative mode Pch PFCEmn WRPFC PFCmn WRPMC (a) Output buffer control PMmn 2nd alternate function 4th alternate function (d) Output data Selection WRPORT Pmn Selector Pmn Selector Internal bus PMCmn WRPM Address (b) Input buffer control RD (e) Alternate function input 2nd alternate function control 3rd alternate function Figure 2-53 Port type Fx210-U block diagram User's Manual U18743EE1V2UM00 95 Chapter 2 Pin Functions 2.4.46 Port type Fx2x0-U EVDD WR PU PUmn WR PFCE (c) Pull- up control Output enable signale 2 in alternative mode Pch PFCEmn WR PFC PFCmn WR PMC Internal bus PMCmn WR PM (a) Output buffer control PMmn 2nd alternate f unction 4th alternate f unction (d) Output data Selection WR PORT Selector Selector Pmn Address (b) Input buffer control RD (e) Alternate function input control 2nd alternate f unction Figure 2-54 96 Port type Fx2x0-U block diagram User's Manual U18743EE1V2UM00 Pmn Pin Functions Chapter 2 2.4.47 Port type Fxx10-U EVDD WR PU PUmn (c) Pull-up control WR PFCE Pch PFCEmn WR PFC PFCmn WR PMC (a) Output buffer control PMmn 4th alternate f unction WR PORT (d) Output data Selection Pmn Selector Pmn Selector Internal bus PMCmn WR PM Address (b) Input buffer control RD (e) Alternate function input 3rd alternate f unction Figure 2-55 control Port type Fxx10-U block diagram User's Manual U18743EE1V2UM00 97 Chapter 2 Pin Functions 2.4.48 Port type Fxx1x-U EVDD WR PU PUmn (c) Pull-up control WR PFCE Pch PFCEmn WR PFC PFCmn Internal bus WR PMC PMCmn WR PM (a) Output buffer control PMmn WR PORT Pmn Selector Selector Pmn Address (b) Input buffer control RD (e) Alternate function input 3rd alternate f unction Figure 2-56 98 Port type Fxx1x-U block diagram User's Manual U18743EE1V2UM00 control Pin Functions Chapter 2 2.4.49 Port type Fxx2x-U EVDD WR PU PU mn WR PFCE (c) Pull- up control Pch Output enable signale 3 in alternative mode PFCEmn WR PFC PFCmn PMCmn WR PM (a) Output buffer control PMmn 3rd alternate f unction WR PORT (d) Output data Selection Pmn Selector Pmn Selector Internal bus WR PMC Address (b) Input buffer control RD (e) Alternate function input control 3rd alternate f unction Figure 2-57 Port type Fxx2x-U block diagram User's Manual U18743EE1V2UM00 99 Chapter 2 Pin Functions 2.5 Port Group Configuration This section provides an overview of the port groups (Table 2-14) and of the pin functions (Table 2-14 on page 100). In Table 2-40 on page 130 it is listed how the pin functions change if the microcontroller is reset. In the subsections, for every port group the settings of the configuration registers is listed. Further, the addresses and initial values of the configuration registers are given. See "Port group 0" on page 108 to "Port group DL" on page 125. 2.5.1 Port group configuration lists Table 2-14 provides an overview of the functions available at each port pin. Table 2-14 V850ES/FE3-L, V850ES/FF3-L, V850ES/FG3-L port group list (1/3) Port group name 0 1a 3 Port name Alternative outputs Alternative inputs P00 TOAA31 TIAA31 5-W P01 TOAA30 TIAA30 5-W P02 TOAA40 NMI/TIAA40 5-W P03 TOAA41 INTP0/TIAA41/ADTRG 5-W P04 - INTP1/CRXD0 5-W P05 - INTP2/DRST 5-AF P06 CTXD0 INTP3 5-W P10 - INTP9 5-W P11 - INTP10 5-W P30 TXDD0 - 5-W P31 - RXDD0/INTP7 5-W P32 TOAA00/TOAA01 ASCKD0/TIAA00 5-W P33 TOAA01/CTXD0 TIAA01 5-W P34 TOAA10 TIAA10/CRXD0 5-W P35 TOAA11 TIAA11 5-W P36a - - 5-W P37a - - 5-W P38b TXDD2a - 5-W P39 - RXDD2a/INTP8a 5-W P40 - SIB0/KR0/ 5-W P41 SOB0 KR1 5-W P42 SCKB0 SCKB0/KR2 5-W P50 - KR0 5-W P51 - KR1 5-W P52 - KR2/DDI 5-W P53 DDO KR3 5-W P54 - KR4/DCK 5-W P55 - KR5/DMS 5-W b 4 5 100 User's Manual U18743EE1V2UM00 Buffer type Pin Functions Table 2-14 Chapter 2 V850ES/FE3-L, V850ES/FF3-L, V850ES/FG3-L port group list (2/3) Port group name 7 Port name Alternative outputs Alternative inputs P70 - ANI0 11-G P71 - ANI1 11-G P72 - ANI2 11-G P73 - ANI3 11-G P74 - ANI4 11-G P75 - ANI5 11-G P76 - ANI6 11-G P77 - ANI7 11-G P78 - ANI8 11-G P79 - ANI9 11-G P710b - ANI10 11-G P711b - ANI11 11-G a - ANI12 11-G P713a - ANI13 11-G P714a - ANI14 11-G a - ANI15 11-G P90 TXDD1 KR6 5-W P91 P712 P715 9 - KR7/RXDD1 5-W a P92 - - 5-W P93a - - 5-W P94a - - 5-W a P95 - - 5-W P96 TOAA21 TIAA21 5-W P97 TOAA20 SIB1/TIAA20 5-W P98 SOB1 - 5-W P99 SCKB1 SCKB1 5-W P910a - - 5-W a - - 5-W P912a - - 5-W P913 PCL INTP4 5-W P914 SDA00 SDA00/INTP5 5-W P915 SCL00 SCL00/INTP6 5-W PCM0 - - 5 PCM1 CLKOUT - 5 PCM2b - - 5 PCM3b - - 5 PCS0 - - 5 PCS1 - - 5 P911 CM CSb Buffer type User's Manual U18743EE1V2UM00 101 Chapter 2 Pin Functions Table 2-14 V850ES/FE3-L, V850ES/FF3-L, V850ES/FG3-L port group list (3/3) Port group name CTb DL Port name Alternative outputs Alternative inputs PCT0 - - 5 PCT1 - - 5 PCT4 - - 5 PCT6 - - 5 PDL0 - - 5-K PDL1 - - 5-K PDL2 - - 5-K PDL3 - - 5-K PDL4 - - 5-K PDL5 - FLMD1 5-K PDL6 - - 5-K PDL7 - - 5-K PDL8b - - 5-K PDL9b - - 5-K PDL10b - - 5-K b - - 5-K PDL12a - - 5-K PDL13a - - 5-K PDL11 a) b) 102 Buffer type V850ES/FG3-L only V850ES/FF3-L, V850ES/FG3-L only User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 User's Manual U18743EE1V2UM00 103 Chapter 2 Pin Functions 2.5.2 Alphabetic pin function list Table 2-15 provides a list of all pin function names in alphabetic order. The table does not list differences between the various devices of the V850ES/ Fx3-L. These are listed in Table 2-14 on page 100. Table 2-15 Pin name I/O Pin function Port Pin number FE3 FF3 FG3 ADTRG I A/D Converter 0 external trigger input P03 15 6 18 ANI0 I A/D Converter 0 input 0 to 15 P70 64 80 100 ANI1 P71 63 79 99 ANI2 P72 62 78 98 ANI3 P73 61 77 97 ANI4 P74 60 76 96 ANI5 P75 59 75 95 ANI6 P76 58 74 94 ANI7 P77 57 73 93 ANI8 P78 56 72 92 ANI9 P79 55 71 91 ANI10 P719 - 70 90 ANI11 P711 - 69 89 ANI12 P712 - - 88 ANI13 P713 - - 87 ANI14 P714 - - 86 ANI15 P715 - - 85 P32 24 24 27 ASCKD0 I UARTD0 baud rate clock input AVREF0 - A/D Converter 0 reference voltage input - 1 1 1 AVSS - A/D Converter 0 ground - 2 2 2 BVDD - I/O buffer supply voltage - - - 70 BVSS - I/O buffer supply ground - - - 69 CLKOUT O CPU system clock output PCM1 46 50 62 CRXD0 I CAN receive data P04 16 7 19 P34 26 26 29 P06 18 18 21 P33 25 25 28 CTXD0 104 Alphabetic pin functions list (1/3) O CAN0 transmit data DCK I N-Wire interface clock P54 34 36 41 DDI I N-Wire interface debug data input P52 30 34 39 DDO O N-Wire interface debug data output P53 31 35 40 DMS I N-Wire interface debug mode select input P55 35 37 42 DRST I N-Wire debug interface reset P05 17 17 20 EVDD - Port buffer supply voltage - 33 31 5, 34 EVSS - Port buffer supply voltage - 32 30 33 User's Manual U18743EE1V2UM00 Pin Functions Table 2-15 Pin name Chapter 2 Alphabetic pin functions list (2/3) I/O Pin function Port Pin number FE3 FF3 FG3 FLMD0 - Flash programming mode setting pin - 3 8 8 FLMD1 I Flash programming mode setting pin PDL5 52 62 76 INTP0 I External interrupts INTP0 - INTP10 P03 15 6 18 INTP1 P04 16 7 19 INTP2 P05 17 17 20 INTP3 P06 18 18 21 INTP4 P913 42 44 56 INTP5 P914 43 45 57 INTP6 P915 44 46 58 INTP7 P31 23 23 26 INTP8 P39 - - 36 INTP9 P10 - - 3 INTP10 P11 - - 4 P40 19 19 22 P50 28 32 37 P41 20 20 23 P51 29 33 38 P42 21 21 24 P52 30 34 39 KR3 P53 31 35 40 KR4 P54 34 36 41 KR5 P55 35 37 42 KR6 P90 36 38 43 KR7 P91 37 39 44 KR0 I Key interrupt KR0 - KR7 KR1 KR2 NMI I Non-maskable interrupt P02 14 5 17 PCL O Programmable clock output P913 42 44 56 REGC - External voltage regulator capacitor connection - 5 10 10 RESET I Reset input - 9 14 14 RXDD0 I UARTD receive data P31 23 23 26 RXDD1 P91 37 39 44 RXDD2 P39 SCKB0 I/O Clocked Serial Interface clock lines I/O I2C0 P42 21 21 24 P99 41 43 52 I/O 2C0 clock line P915 44 46 58 data line P914 43 45 57 P40 19 19 22 P97 39 41 50 P41 20 20 23 P98 40 42 51 SCKB1 SCL00 SDA00 SIB0 I I Clocked Serial Interface data input SIB1 SOB0 O 36 Clocked Serial Interface data output SOB1 User's Manual U18743EE1V2UM00 105 Chapter 2 Pin Functions Table 2-15 Pin name Port Timer TAA channel 0 capture trigger input P32 24 24 27 TIAA10 P33 25 25 28 TIAA20 P97 39 41 50 TIAA30 P01 13 4 7 TIAA40 P02 14 5 17 P34 26 26 29 TIAA11 P35 27 27 30 TIAA21 P96 38 40 49 TIAA31 P00 12 3 6 TIAA41 P03 15 6 18 P32 24 24 27 TOAA10 P34 26 26 29 TOAA20 P97 39 41 50 TOAA30 P01 13 4 7 TOAA40 P02 14 5 17 P32 24 24 27 P33 25 25 28 TOAA11 P35 27 27 30 TOAA21 P96 38 40 49 TOAA31 P00 12 3 6 TOAA41 P03 15 6 18 P30 22 22 25 TXDD1 P90 36 38 43 TXDD2 P38 TIAA01 TOAA00 TOAA01 TXDD0 I/O Pin number Pin function TIAA00 106 Alphabetic pin functions list (3/3) I I O O O Timer TAA channel 1 capture trigger input Timer TAA channel 0 signal output Timer TAA channel 1 signal output UARTD transmit data FE3 FF3 FG3 35 VDD - Core supply voltage - 4 9 9 VSS - Core supply ground - 6 11 11 X1 I Main clock resonator connection - 7 12 12 X2 - Main clock resonator connection - 8 13 13 XT1 I Sub oscillator resonator connection - 10 15 15 XT2 - Sub oscillator resonator connection - 11 16 16 User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 Note The following alternative functions are provided on two pins each: Unit Alternative function Timer TOAA01 CAN Key interrupt I/O Port 1 Port 2 O P33 P32 CTXD0 O P06 P33 CRXD0 I P04 P34 KR0 I P40 P50 KR1 I P41 P51 KR2 I P42 P52 Thus you can select on which pin the alternative function should appear. Refer to "Pin function configuration" on page 37. Caution Make sure an alternative input function is only supplied from a single pin at the same time. An alternative output function can be output on several pins concurrently. For example, if P40 operates as key interrupt KR0, P50 must not operate as key interrupt KR0. User's Manual U18743EE1V2UM00 107 Chapter 2 Pin Functions 2.5.3 Port group 0 Port group 0 is a 7-bit port group. In alternative mode, it comprises pins for the following functions: * External interrupt (INTP0 to INTP3) * Non-maskable interrupt (NMI) * N-Wire debug interface reset (DRST) * A/D Converter 0 external trigger input (ADTRG) * Timer TAA3 channels (TIAA30, TIAA31 and TOAA30, TOAA31) * Timer TAA4 channels (TIAA40, TIAA41 and TOAA40, TOAA41) * CAN0 transmit/receive data (CTXD0, CRXD0) Port group 0 includes the following pins: Table 2-16 Port group 0: pin functions and port types Pin functions in different modes Port mode (PMC = 0) Alternative mode (PMCnm = 1) PFCE = 0 PFCE = 1 Pin function after reset Port type Noise Input filtera charact.b Function 1 PFC = 0 Function 2 PFC = 1 P00 TIAA31 (I) TOAA31 (O) - - - P00 (I) E10-U A S2 P01 TIAA30 (I) TOAA30 (O) - - - P01 (I) E10-U A S2 P02 NMI (I) prohibited TIAA40 (I) TOAA40 (O) - P02 (I) F1x10-UI A S2 P03 INTP0 (I) ADTRG (I) TIAA41 (I) TOAA41 (O) - P03 (I) F1110-UI A S2 P04 INTP1 (I) CRXD0 (I) - - - P04 (I) E11-UI A S1 P05 INTP2 (I) - - - DRST (I) P05 (I) or DRST (I) c D101-UI A S2 P06 INTP3 (I) CTXD0 (O) - - - P06 (I) E10-UI B S2 a) b) c) Function 4 PFC = 1 A: analog noise filter only for TIAAnm, NMI, INTPn, DRST, ADTRG inputs B: analog and digital noise filter -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS The pin function after reset depends on the reset source, that means on bit OCDM.OCDM0. Refer to "OCDM - On-chip debug mode register" on page 42 and to "On-Chip Debug Unit" on page 723. Note 108 Function 3 PFC = 0 On-chip debug mode (OCDM0 = 1) Alternative functions CRXD0 and CTXD0 are provided on two pins each. Thus you can select on which pin the alternative function should appear. Refer to "Alphabetic pin function list" on page 104. User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 Table 2-17 Port group 0: configuration registers Register Address Initial value Used bits PMC0 FFFF F440 H 00 H X PMC06 PMC05 PMC04 PMC03 PMC02 PMC01 PMC00 PM0 FFFF F420 H FF H X PM06 PM05 PM04 PM03 PM02 PM01 PM00 PFC0 FFFF F460 H 00 H X PFC06 X PFC04 PFC03 PFC02 PFC01 PFC00 PFCE0 FFFF F700 H 00 H X X X X PFCE03 PFCE02 X X a 0 0 0 0 0 0 0 OCDM0 OCDM FFFF F9FC H 00 H / 01 H P0 FFFF F400 H undefined X P06 P05 P04 P03 P02 P01 P00 PU0 FFFF FC40 H 00 H X PU06 PU05 PU04 PU03 PU02 PU01 PU00 a) Depends on the reset source (Refer to "OCDM - On-chip debug mode register" on page 42 and to "On-Chip Debug Unit" on page 723) Access All 8-bit registers can be accessed in 8-bit or 1-bit units. User's Manual U18743EE1V2UM00 109 Chapter 2 Pin Functions 2.5.4 Port group 1 (V850ES/FG3-L) Note Port group 1 is available only for V850ES/FG3-L. Port group 1 is a 2-bit port group. In alternative mode, it comprises pins for the following functions: * External interrupt (INTP9 and INTP10) Port group 1 includes the following pins: Table 2-18 Port group 1: pin functions and buffer types Pin functions in different modes Port mode (PMCnm = 0) Port type Noise Input filtera charact.b P10 INTP9 (I) P10 (I) D1-UI A S2 P11 INTP10 (I) P11 (I) D1-UI A S2 a) b) Table 2-19 Pin function after reset Alternative mode (PMCnm = 1) A: analog noise filter only for INTPn inputs B: analog and digital noise filter -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS Port group 1: configuration registers Register Address Initial value Used bits PMC1 FFFF F442H 00H X X X X X X PMC11 PMC10 PM1 FFFF F422H FFH X X X X X X PM11 PM10 P1 FFFF F402H undefined X X X X X X P11 P10 PU1 FFFF FC42H 00H X X X X X X PU11 PU10 Access 110 All 8-bit registers can be accessed in 8-bit or 1-bit units. User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.5.5 Port group 3 Port group 3 is a 10-bit port group. In alternative mode, it comprises pins for the following functions: * External interrupt (INTP7 and INTP8) * Timer TAA0 channels (TIAA00, TIAA01 and TOAA00, TOAA01) * Timer TAA1 channels (TIAA10, TIAA11 and TOAA10, TOAA11) * CAN0 transmit/receive data (CTXD0, CRXD0) * UARTD0 transmit/receive data (TXDD0, RXDD0) * UARTD0 baud rate clock input (ASCKD0) Port group 3 includes the following pins: Table 2-20 Port group 3: pin functions and buffer types Pin functions in different modes Port mode (PMCnm = 0) Alternative mode (PMCnm = 1) PFCE = 0 Function 1 PFC = 0 Function 2 PFC = 1 PFCE = 1 Function 3 PFC = 0 Function 4 PFC = 1 Pin function after reset P30 TXDD0 (O) - - - P30 (I) P31 RXDD0 (I) INTP7 (I) - - - P31 (I) P32 ASCKD0 (I) TOAA01 (O) TIAA00 (I) TOAA00 (O) P33 TIAA01 (I) TOAA01 (O) CTXD0 (O) P34 TIAA10 (I) TOAA10 (O) P35 Port type Noise filtera Input charact. b D0-U - S1 D3-UI A S1 P32 (I) F1010-U A S2 prohibited P33 (I) F100x-U A S2 CRXD0 (I) prohibited P34 (I) F101x-U A S1 TIAA11 (I) TOAA11 (O) - - P35 (I) E10-U A S2 P36c - - - - P36 (I) C-U - S1 c - - - - P37 (I) C-U - S1 P38 (I) C-Ud - S1 A S1 P37 P38c TXDD2(O)c - - - D0-U P39c a) b) c) d) RXDD2 (I)c/ - INTP8 (I)c - - P39 (I) C-Ud D3-UI A: analog noise filter only for INTPn, TIAAnm inputs B: analog and digital noise filter -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS not available for V850ES/FE3-L, V850ES/FF3-L for V850ES/FF3-L x Note Alternative functions CRXD0, CTXD0, and TOAA01 are provided on two pins each. Thus you can select on which pin the alternative function should appear. Refer to "Pin function configuration" on page 37. User's Manual U18743EE1V2UM00 111 Chapter 2 Pin Functions Table 2-21 Port group 3: configuration registers Address Initial value Used bits PMC3L FFFF F446 H 00 H X X PMC35 PMC34 PMC33 PMC32 PMC31 PMC30 PM3L FFFF F426 H FF H X X PM35 PM34 PM33 PM32 PM31 PM30 PFC3L FFFF F466 H 00 H X X PFC35 PFC34 PFC33 PFC32 X X PFCE3L FFFF F706 H 00 H X X X PFEC34 PFCE33 PFCE32 X X P3L FFFF F406 H undefined X X P35 P34 P33 P32 P31 P30 PU3L FFFF FC46 H 00 H X X PU35 PU34 PU33 PU32 PU31 PU30 PMC3L FFFF F446 H 00 H X X PMC35 PMC34 PMC33 PMC32 PMC31 PMC30 PM3L FFFF F426 H FF H X X PM35 PM34 PM33 PM32 PM31 PM30 PM3H FFFF F427 H FF H X X X X X X PM39 PM38 PM3 (16 bit) FFFF F426 H FFFF H PFC3L FFFF F466 H 00 H X X PFC35 PFC34 PFC33 PFC32 X X PFCE3L FFFF F706 H 00 H X X X PFEC34 PFCE33 PFCE32 X X P3L FFFF F406 H undefined X X P35 P34 P33 P32 P31 P30 P3H FFFF F407 H undefined X X X X X X P39 P38 P3 (16 bit) FFFF F406 H undefined PU3L FFFF FC46 H 00 H X X PU35 PU34 PU33 PU32 PU31 PU30 PU3H FFFF FC47 H 00 H X X X X X X PU39 PU38 PU3 (16 bit) FFFF FC46 H 0000 H PMC3L FFFF F446 H 00 H PMC37 PMC36 PMC35 PMC34 PMC33 PMC32 PMC31 PMC30 PMC3H FFFF F447 H 00 H X X X X X X PMC39 PMC38 PMC3 (16 bit) FFFF F446 H 0000 H PM3L FFFF F426 H FF H PM37 PM36 PM35 PM34 PM33 PM32 PM31 PM30 PM3H FFFF F427 H FF H X X X X X X PM39 PM38 PM3 (16 bit) FFFF F426 H FFFF H PFC3L FFFF F466 H 00 H X X PFC35 PFC34 PFC33 PFC32 X X PFCE3L FFFF F706 H 00 H X X X PFEC34 PFCE33 PFCE32 X X P3L FFFF F406 H undefined P37 P36 P35 P34 P33 P32 P31 P30 P3H FFFF F407 H undefined X X X X X X P39 P38 P3 (16 bit) FFFF F426 H undefined PU3L FFFF FC46 H 00 H PU37 PU36 PU35 PU34 PU33 PU32 PU31 PU30 PU3H FFFF FC47 H 00 H X X X X X X PU39 PU38 PU3 (16 bit) FFFF FC46 H 0000 H Register V850ES/FE3-L V850ES/FF3-L PM315 to PM38 (PM3H) PM37 to PM30 (PM3L) P315 to P38 (P3H) P37 to P30 (P3L) PU315 to PU38 (PU3H) PU37 to PU30 (PU3L) V850ES/FG3-L Access PMC315 to PMC38 (PMC3H) PMC37 to PMC30 (PMC3L) PM315 to PM38 (PM3H) PM37 to PM30 (PM3L) P315 to P38 (P3H) P37 to P30 (P3L) PU315 to PU38 (PU3H) All 8-bit registers can be accessed in 8-bit or 1-bit units. All 16-bit registers can be accessed in 16-bit units. 112 PU37 to PU30 (PU3L) User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.5.6 Port group 4 Port group 4 is a 3-bit port group. In alternative mode, it comprises pins for the following functions: * External interrupt (INTP14) * Key interrupt input (KR0 to KR2) * Clocked Serial Interface CSIB0 data/clock line (SIB0, SOB0, SCKB0) Port group 4 includes the following pins: Table 2-22 Port group 4: pin functions and buffer Pin functions in different modes Port mode (PMCnm = 0) Alternative mode (PMCnm = 1) PFCE = 0 Pin function after reset PFCE = 1 Port type Noise Input filtera charact.b Function 1 PFC = 0 Function 2 PFC = 1 Function 3 PFC = 0 Function 4 PFC = 1 P40 SIB0 (I) KR0 (I) - - P40 (I) E11-U A S1 P41 SOB0 (O) KR1 (I) - - P41 (I) E01-U A S2 P42 SCKB0 (I/O) KR2 (I) - - P42 (I) E21-U A S2 a) b) A: analog noise filter only for KRn, INTPn inputs B: analog and digital noise filter -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS Note Table 2-23 Alternative functions KR0 to KR2 are provided on two pins each. Thus you can select on which pin the alternative function should appear. Refer to "Pin function configuration" on page 37. Port group 4: configuration registers Register Address Initial value Used bits PMC4 FFFF F448 H 00 H X X X X X PMC42 PMC41 PMC40 PM4 FFFF F428 H FF H X X X X X PM42 PM41 PM40 PFC4 FFFF F468 H 00 H X X X X X PFC42 PFC41 PFC40 P4 FFFF F408 H undefined X X X X X P42 P41 P40 PU4 FFFF FC48 H 00 H X X X X X PU42 PU41 PU40 Access All 8-bit registers can be accessed in 8-bit or 1-bit units. User's Manual U18743EE1V2UM00 113 Chapter 2 Pin Functions 2.5.7 Port group 5 Port group 5 is an 8-bit port group. In alternative mode, it comprises pins for the following functions: * Key interrupt input 0 to 5 (KR0 to KR5) * N-Wire debug interface signals (DDI, DDO, DCK, DMS) Port group 5 includes the following pins: Table 2-24 Port group 5: pin functions and buffer types Pin functions in different modes Port mode (PMC = 0) Alternative mode (PMCnm = 1) PFCE = 0 PFCE = 1 Port type Noise filtera Input charact. b Function 2 PFC = 1 P50 KR0 (I) - - - - P50 (I) D1-U A S2 P51 KR1 (I) - - - - P51 (I) D1-U A S2 P52 KR2 (I) - - - DDI (I) P52 (I) or DDI (I) c D101-U A S2 P53 KR3 (I) - - - DDO (O) P53 (I) or DDO (O) c D101-U A S2 P54 KR4 (I) - - - DCK (I) P54 (I) or DCK (I) c D101-U A S2 P55 KR5 (I) - - - DMS (I) P55 (I) or DMS (I) c D101-U A S2 b) c) A: analog noise filter only for KRn, TIABnm inputs B: analog and digital noise filter -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS The pin function after reset depends on the reset source, that means on bit OCDM.OCDM0. Refer to "OCDM - On-chip debug mode register" on page 42 and to "On-Chip Debug Unit" on page 723. Note 114 Function 4 PFC = 1 Pin function after reset Function 1 PFC = 0 a) Function 3 PFC = 0 On-chip debug mode (OCDM0 = 1) Alternative functions KR0 to KR2 are provided on two pins each. Thus you can select on which pin the alternative function should appear. Refer to "Pin function configuration" on page 37. User's Manual U18743EE1V2UM00 Pin Functions Table 2-25 Chapter 2 Port group 5: configuration registers Register Address Initial value Used bits PMC5 FFFF F44A H 00 H PM5 FFFF F42A H FF H X X PMC55 PMC54 PMC53 PMC52 PMC51 PMC50 X X PM55 PM54 PM53 PM52 PM51 PM50 a 0 0 0 0 0 0 0 OCDM0 OCDM FFFF F9FC H 00 H / 01 H P5 FFFF F40A H undefined X X P55 P54 P53 P52 P51 P50 PU5 FFFF FC4A H 00 H X X PU55 PU54 PU53 PU52 PU51 PU50 a) Depends on the reset source (Refer to "OCDM - On-chip debug mode register" on page 42 and to "On-Chip Debug Unit" on page 723) Access All 8-bit registers can be accessed in 8-bit or 1-bit units. User's Manual U18743EE1V2UM00 115 Chapter 2 Pin Functions 2.5.8 Port group 7 Port group 7 is a 16-bit port group. It includes pins for the following functions: * A/D Converter 0 inputs Port group 7 includes the following pins: Table 2-26 Port group 7: pin functions and buffer types Pin functions in different modes Port mode (PMCnm = 0) Pin function after reset Port type Noise Input filtera charact.b P70 ANI0 (I) P70 (I) D1A - x P71 ANI1 (I) P71 (I) D1A - x P72 ANI2 (I) P72 (I) D1A - x P73 ANI3 (I) P73 (I) D1A - x P74 ANI4 (I) P74 (I) D1A - x P75 ANI5 (I) P75 (I) D1A - x P76 ANI6 (I) P76 (I) D1A - x P77 ANI7 (I) P77 (I) D1A - x P78 ANI8 (I) P78 (I) D1A - x P79 ANI9 (I) P79 (I) D1A - x P710c ANI10 (I) P710 (I) D1A - x P711c ANI11 (I) P711 (I) D1A - x P712d ANI12 (I) P712 (I) D1A - x d ANI13 (I) P713 (I) D1A - x P714d ANI14 (I) P714 (I) D1A - x P715d ANI15 (I) P715 (I) D1A - x P713 a) b) c) d) 116 Alternative mode (PMCnm = 1) A: analog noise filter; B: analog and digital noise filter; -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS not available for V850ES/FE3-L not available for V850ES/FE3-L and V850ES/FF3-L User's Manual U18743EE1V2UM00 Pin Functions Table 2-27 Chapter 2 Port group 7: configuration registers Register Address Initial value Used bits PMC7L FFFF F44E H 00 H PMC77 PMC7H FFFF F44F H 00 H PMC715 PM7L FFFF F42E H FF H PM77 PM7H FFFF F42F H FF H PM715 P7L FFFF F40E H undefined P77 P7H a) b) FFFF F40F H undefined P715 PMC76 a PMC714 PMC75 a PM76 a PM714 PM75 a P76 a P714 PMC713 PM713 P75 a P713 PMC74 a PMC712 PM74 a PM712 P74 a P712 PMC73 a PMC711 PM73 a PM711 P73 a P711 PMC72 b PMC710 PM72 b PM710 P72 b P710 b b b PMC71 PMC70 PMC79 PMC78 PM71 PM70 PM79 PM78 P71 P70 P79 P78 not available for V850ES/FE3-L and V850ES/FF3-L not available for V850ES/FE3-L Access All 8-bit registers can be accessed in 8-bit or 1-bit units. All 16-bit registers can be accessed in 16-bit units. Caution The port status cannot be read if the port is used as an analog input. User's Manual U18743EE1V2UM00 117 Chapter 2 Pin Functions 2.5.9 Port group 9 Port group 9 is an 16-bit port group. In alternative mode, it comprises pins for the following functions: * External interrupt (INTP4 to INTP6) * Key interrupt input 6 to 7 (KR6 to KR7) * Timer TAA2 channels (TIAA20, TIAA21 and TOAA20, TOAA21) * Clocked Serial Interface CSIB1 data/clock line (SOB1, SIB1, SCKB1) * UARTD1 transmit/receive data (TXDD1, RXDD1) * I2C data/clock line (SDA00, SCL00) * Programmable clock output (PCL) Note 118 If P914 and P915 are in output port mode (PMC9.PMC9m = 0 and PM9.PM9m = 0), the PF9H register specifies normal output or open-drain output. User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 Table 2-28 Port group 9: pin functions and buffer types Pin functions in different modes Port mode (PMCnm = 0) Alternative mode (PMCnm = 1) PFCE = 0 PFCE = 1 Pin function after reset Port type Noise filtera Input charact.b Function 1 PFC = 0 Function 2 PFC = 1 Function 3 PFC = 0 Function 4 PFC = 1 P90 prohibited KR6 (I) TXDD1 (O) prohibited P90 (I) Fx10x -U A S2 P91 prohibited KR7 (I) RXDD1 (I) KR7 (I) prohibited P91 (I) Fx13x -U A S1 P92c - - - - P92 (I) C-U - S2 P93c - - - - P93 (I) C-U - S2 c P94 - - - - P94 (I) C-U - S2 P95c - - - - P95 (I) C-U - S2 P96 prohibited prohibited TIAA21 (I) TOAA21 (O) P96 (I) Fxx10 -U A S2 P97 prohibited SIB1 (I) TIAA20 (I) TOAA20 (O) P97 (I) Fx110 -U A S2 P98 prohibited SOB1 (O) prohibited prohibited P98 (I) Ex0-U - S2 prohibited SCKB1 (I/O) prohibited prohibited P99 (I) Ex2-U A S2 P99 c - - - - P910 (I) C-U - S2 P911c - - - - P911 (I) C-U - S1 c - - - - P912 (I) C-U - S2 P910 P912 P913 prohibited INTP4 PCL (O) INTP4 (I) P913 (I) Fx10x -UI A S1 P914 prohibited INTP5 SDA00 (I/O) INTP5 (I) P914 (I) Fx12x -UFI A S1 P915 prohibited INTP6 SCL00 (I/O) prohibited P915 (I) Fx12x -UFI A S1 a) b) c) A: analog noise filter only for KRn, TIABnm inputs B: analog and digital noise filter -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS not available for V850ES/FE3-L and V850ES/FF3-L User's Manual U18743EE1V2UM00 119 Chapter 2 Pin Functions Table 2-29 Port group 9: V850ES/FE3-L, V850ES/FF3-L configuration registers Register Address Initial value Used bits PMC9L FFFF F452 H 00 H PMC97 PMC96 X X X X PMC91 PMC90 PMC9H FFFF F453 H 00 H PMC915 PMC914 PMC913 X X X PMC99 PMC98 PMC9 (16 bit) FFFF F452 H 0000 H PM9L FFFF F432 H FF H PM97 PM96 X X X X PM91 PM90 PM9H FFFF F433 H FF H PM915 PM914 PM913 X X X PM99 PM98 PM9 (16 bit) FFFF F432 H FFFF H PFC9L FFFF F472 H 00 H PFC97 PFC96 X X X X PFC91 PFC90 PFC9H FFFF F473 H 00 H PFC915 PFC914 PFC913 X X X PFC99 PFC98 PFC9 (16 bit) FFFF F472 H 0000 H PFCE9L FFFF F712 H 00 H PFCE97 PFCE96 X X X X PFCE91 PFCE90 PFCE9H FFFF F713 H 00 H PFCE915 PFCE914 PFCE913 X X X X X PFCE9 (16 bit) FFFF F712 H 0000 H P9L FFFF F412 H undefined P97 P96 X X X X P91 P90 P9H FFFF F413 H undefined P915 P914 P913 X X X P99 P98 P9 (16 bit) FFFF F412 H undefined PU9L FFFF FC52 H 00 H PU97 PU96 X X X X PU91 PU90 PU9H FFFF FC53 H 00 H PU915 PU914 PU913 X X X PU99 PU98 PU9 (16 bit) FFFF FC52 H 0000 H PF9H FFFF FC73 H 00 H Access PMC915 to PMC98 (PMC9H) PMC97 to PMC90 (PMC9L) PM915 to PM98 (PM9H) PM97 to PM90 (PM9L) PFC915 to PFC98 (PFC9H) PFC97 to PFC90 (PFC9L) PFCE915 to PFCE98 (PFCE9H) PFCE97 to PFCE90 (PFCE9L) P915 to P98 (P9H) P97 to P90 (P9L) PU915 to PU98 (PU9H) PF915 PF914 X PU97 to PU90 (PU9L) X X All 8-bit registers can be accessed in 8-bit or 1-bit units. All 16-bit registers can be accessed in 16-bit units. 120 X User's Manual U18743EE1V2UM00 X X Pin Functions Table 2-30 Chapter 2 Port group 9: V850ES/FG3-L configuration registers Register Address Initial value Used bits PMC9L FFFF F452 H 00 H PMC97 PMC96 X X X X PMC91 PMC90 PMC9H FFFF F453 H 00 H PMC915 PMC914 PMC913 X X X PMC99 PMC98 PMC9 (16 bit) FFFF F452 H 0000 H PM9L FFFF F432 H FF H PM97 PM96 PM95 PM94 PM93 PM92 PM91 PM90 PM9H FFFF F433 H FF H PM915 PM914 PM913 PM912 PM911 PM910 PM99 PM98 PM9 (16 bit) FFFF F432 H FFFF H PFC9L FFFF F472 H 00 H PFC97 PFC96 X X X X PFC91 PFC90 PFC9H FFFF F473 H 00 H PFC915 PFC914 PFC913 X X X PFC99 PFC98 PFC9 (16 bit) FFFF F472 H 0000 H PFCE9L FFFF F712 H 00 H PFCE97 PFCE96 X X X X PFCE91 PFCE90 PFCE9H FFFF F713 H 00 H PFCE915 PFCE914 PFCE913 X X X X X PFCE9 (16 bit) FFFF F712 H 0000 H P9L FFFF F412 H undefined P97 P96 P95 P94 P93 P92 P91 P90 P9H FFFF F413 H undefined P915 P914 P913 P912 P911 P910 P99 P98 P9 (16 bit) FFFF F412 H undefined PU9L FFFF FC52 H 00 H PU97 PU96 PU95 PU94 PU93 PU92 PU91 PU90 PU9H FFFF FC53 H 00 H PU915 PU914 PU913 PU912 PU911 PU910 PU99 PU98 PU9 (16 bit) FFFF FC52 H 0000 H PF9H FFFF FC73 H 00 H Access PMC915 to PMC98 (PMC9H) PMC97 to PMC90 (PMC9L) PM915 to PM98 (PM9H) PM97 to PM90 (PM9L) PFC915 to PFC98 (PFC9H) PFC97 to PFC90 (PFC9L) PFCE915 to PFCE98 (PFCE9H) PFCE97 to PFCE90 (PFCE9L) P915 to P98 (P9H) P97 to P90 (P9L) PU915 to PU98 (PU9H) PF915 PF914 X PU97 to PU90 (PU9L) X X X X X All 8-bit registers can be accessed in 8-bit or 1-bit units. All 16-bit registers can be accessed in 16-bit units. User's Manual U18743EE1V2UM00 121 Chapter 2 Pin Functions 2.5.10 Port group CM Port group CM is a 6-bit port group. In alternative mode, it comprises pins for the following functions: * CPU system clock output (CLKOUT) Port group CM includes the following pins: Table 2-31 Port group CM: pin functions and buffer types Pin functions in different modes Port mode (PMCnm = 0) PCM0 (I) C - x PCM1 CLKOUT (O) PCM1 (I) D0 - x PCM2c - PCM2 (I) C - x PCM3c - PCM3 (I) C - x c) A: analog noise filter; B: analog and digital noise filter; -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS Not available on V850ES/FE3-L Port group CM: configuration registers Register Address Initial value Used bits PMCCM FFFF F04C H 00 H X PCM a) FFFF F02C H FFFF F00C H 122 FF H undefined X X X X X X X X X X X PMCCM1 X X PMCM3 a PMCM2 PMCM1 PMCM0 X PCM3 a PCM2 a PCM1 PCM0 not available for V850ES/FE3-L Access Noise Input filtera charact.b - a) PMCM Port type PCM0 b) Table 2-32 Pin function after reset Alternative mode (PMCnm = 1) All 8-bit registers can be accessed in 8-bit or 1-bit units. User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.5.11 Port group CS (V850ES/FF3-L, V850ES/FG3-L) Note Port group CS is available only for V850ES/FF3-L, V850ES/FG3-L Port group CS is an 8-bit port group. In alternative mode, it comprises pins for the following functions: Port group CS includes the following pins: Table 2-33 Port group CS: pin functions and buffer types Pin functions in different modes Port mode (PMCnm = 0) Alternative mode (PMCnm = 1) Port type Noise filtera Input charact.b PCS0 - PCS0 (I) C - x PCS1 - PCS1 (I) C - x a) b) Table 2-34 Pin function after reset A: analog noise filter; B: analog and digital noise filter; -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS Port group CS: configuration registers Register Address Initial value Used bits PMCS FFFF F028 H FF H X X X X X X PMCS1 PMCS0 PCS FFFF F008 H undefined X X X X X X PCS1 PCS0 Access All 8-bit registers can be accessed in 8-bit or 1-bit units. User's Manual U18743EE1V2UM00 123 Chapter 2 Pin Functions 2.5.12 Port group CT (V850ES/FF3-L, V850ES/FG3-L) Note Port group CT is available only for V850ES/FF3-L, V850ES/FG3-L. Port group CT is an 8-bit port group. In alternative mode, it comprises pins for the following functions: Port group CT includes the following pins: Table 2-35 Port group CT: pin functions and buffer types Pin functions in different modes Port mode (PMCnm = 0) Pin function after reset Port type Noise filtera Input charact.b PCT0 - PCT0 (I) C - x PCT1 - PCT1 (I) C - x PCT4 - PCT4 (I) C - x PCT6 - PCT6 (I) C - x a) b) Table 2-36 Alternative mode (PMCnm = 1) A: analog noise filter; B: analog and digital noise filter; -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS Port group CT: configuration registers Register Address Initial value Used bits PMCT FFFF F02A H FF H X PMCT6 X PMCT4 X X PMCT1 PMCT0 PCT FFFF F00A H undefined X PCT6 X PCT4 X X PCT1 PCT0 Access 124 All 8-bit registers can be accessed in 8-bit or 1-bit units. User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.5.13 Port group DL Port group DL is an 16-bit input/output port group. Port group DL includes the following pins: Table 2-37 Port group DL: pin functions and buffer types Pin functions in different modes Port mode (PMCnm = 0) PDL0 (I) C - S2 PDL1 - PDL1 (I) C - S2 PDL2 - PDL2 (I) C - S2 PDL3 - PDL3 (I) C - S2 PDL4 - PDL4 (I) C - S2 PDL5 (I) C - S2 FLMD1 (I) PDL6 - PDL6 (I) C - S2 PDL7 - PDL7 (I) C - S2 PDL8c - PDL8 (I) C - S2 - PDL9 (I) C - S2 c - PDL10 (I) C - S2 PDL11c - PDL11 (I) C - S2 PDL12d - PDL12 (I) C - S2 c - PDL13 (I) C - S2 PDL10 PDL13 a) b) c) d) A: analog noise filter; B: analog and digital noise filter; -: no noise filter S1: Schmitt trigger (30/70%); S2: Schmitt trigger (40/80%); x: CMOS not available for V850ES/FE3-L not available for V850ES/FE3-L, V850ES/FF3-L Port group DL: configuration registers Register Address Initial value Used bits PMDLL FFFF F024 H FF H PMDL7 PMDLH PMDL (16 bit) a PDLL PDLH a PDL (16 a) b) bit) a Noise Input filtera charact.b - PDL9c a Port type PDL0 PDL5 Table 2-38 Pin function after reset Alternative mode (PMCnm = 1) FFFF F025 H FF H FFFF F024 H FFFF H FFFF F004 H undefined FFFF F005 H undefined FFFF F004 H undefined X PMDL6 PMDL5 PMDL4 PMDL3 PMDL2 PMDL1 PMDL0 X PMDL13 b PMDL12 b PMDL11 a PMDL10 a PMDL9 PMDL8 PMDL15 to PMDL8 (PMDLH) PDL7 X PMDL7 to PMDL0 (PMDLL) PDL6 PDL5 PDL4 PDL3 PDL2 PDL1 PDL0 X PDL13 b PDL12 b PDL11 a PDL10 a PDL9 PDL8 PDL15 to PDL8 (PDLH) PDL7 to PDL0 (PDLL) not available for V850ES/FE3-L not available for V850ES/FE3-L, V850ES/FF3-L Access All 8-bit registers can be accessed in 8-bit or 1-bit units. All 16-bit registers can be accessed in 16-bit units. User's Manual U18743EE1V2UM00 125 Chapter 2 Pin Functions 2.6 Noise Elimination The input signals at some pins are passing a filter to remove noise and glitches. The microcontroller supports both analog and digital filters. In Table 2-16 on page 108 and in the following tables it is listed whether a pin is equipped with an analog filter, a digital filter, both analog and digital filter, or no filter at all. 2.6.1 Analog filtered inputs The following input signals are passed through an analog filter to remove noise and glitches: * Non-maskable interrupt (NMI) * External interrupts (INTPn) * Key interrupt inputs (KRn) * Timer TAA trigger inputs (TIAAnm) * A/D converter external input triggers (ADTRG) * N-Wire debug interface reset (DRST) The analog filter suppresses input pulses that are shorter than a specified pulse width (refer to the Electrical Target Specification). This assures the hold time for the external interrupt signals. The analog filter operates in all modes (normal mode and standby modes). It is only effective if the corresponding pin works in alternative input mode and not as a general purpose I/O port. 126 User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.6.2 Digitally filtered inputs The input signal INTP3 is passed through both an analog and a digital filter. The digital filter operates in all modes, in which fXX is available. Thus, it does not operate in standby modes (if fXT is used as the sampling clock, it can operate in standby modes). The digital filter is only effective if the corresponding pin works in alternative input mode and not as a general purpose I/O port. Filter operation The input terminal signal is sampled with the sampling frequency fs. Spikes shorter than N-1 sampling cycles are suppressed and no internal signal is generated. Pulses longer than N sampling cycles are recognized as valid pulses and an internal signal is generated. The pulses between N-1 and N sampling cycles are eliminated as noise, or detected as a valid edge. The characteristics of the digital filter can be set by the NFC register. The characteristic of the digital noise filter is determined by the register NFC: * fs is defined by NFC.NFC[2:0] fs is the sampling frequency. Together with N it defines the minimum input terminal pulse width to be validated. * N is defined by NFC.NFSTS Possible values for N are 2 or 3. The filter operation is illustrated in Figure 2-58 for NFC.NFSTS = 0 (N = 3). Input terminal Filter output Figure 2-58 Digital noise removal example for NFC.NFSTS = 0 (N = 3) User's Manual U18743EE1V2UM00 127 Chapter 2 Pin Functions (1) NFC - Digital noise filter control register The 8-bit NFC register specifies the noise elimination circuit for signal INTP3. Access Address Initial Value Table 2-39 This register can be read/written in 8-bit and 1-bit units. FFFF F318H 00H. This register is cleared by any reset. 7 6 5 NFEN NFSTS 0 R/W R/W R 4 3 2 1 0 0 0 NFC2 NFC1 NFC0 R R R/W R/W R/W NFC register contents Bit position Bit name Function 7 NFEN Enables/disables digital noise elimination at pin INTP3: 0: Digital noise elimination is disabled. 1: Digital noise elimination is enabled. 6 NFSTS Defines the number of sampling periods N of fs to validate the external signal: 0: N = 3 1: N = 2 Defines the sampling frequency fs for digital noise removal: 2 to 0 NFC2 NFC1 NFC0 Sampling frequency fs 0 0 0 fxx/64 0 0 1 fxx/128 0 1 0 fxx/256 0 1 1 fxx/512 1 0 0 fxx/1024 1 0 1 fxt 1 1 0 1 1 1 NFC[2:0] setting prohibited Note 128 1. fxx = system clock fxt = Sub oscillator frequency). Remark If fs is set to fXX/64, fXX/128, fXX/256, fXX/512, fXX/1024, or fXX/2048, it cannot be used to release the standby mode, because the sampling clock stops in the IDLE1, IDLE2 mode, or STOP mode. In this case, set fs to fXT or connect the analog noise elimination circuit (setting not to execute digital noise elimination) to release the standby mode. Caution After the sampling clock has been changed, it takes N sampling clocks (defined sampling frequency N = 3 or 2) to initialize the digital noise eliminator. Therefore, if an INTP3 valid edge is input within these N sampling clocks time after the sampling clock has been changed, an interrupt request signal may be generated. Therefore, be careful about the following points when using the interrupt and User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 DMA functions. When using the interrupt function, after the N sampling clocks (selected sampling frequency N = 3 or 2) have elapsed, enable interrupts after the interrupt request flag (PIC3.PIF3 bit) has been cleared. When using the DMA function (started by INTP3), enable DMA after the N sampling clocks have elapsed. User's Manual U18743EE1V2UM00 129 Chapter 2 Pin Functions 2.7 Pin Functions in Reset and Power Save Modes The following table summarizes the status of the pins during reset and power save modes and after release of these operating states in normal operation mode. The reset source makes a difference concerning the N-Wire debugger interface pins DRST, DDI, DDO, DCK and DMS after reset release. An external RESET or an internal Power-On-Clear switches all pins to input port mode, while all other internal reset sources make the pins available for the debugger. In contrast to all other power save modes the HALT mode suspends only the CPU operation and has no effect on any pin status. m Table 2-40 Pin functions and reset / power save modes Operating status external RESET Pin status during * P05/DRST: P05 port input with internal pull-down resistor * all other pins: Hi-impedence after * * * * during * P05/DRST: P05 port input with internal pull-down resistor * all other pins: Hi-impedence after input port mode all other reset sources during after * P05/DRST, P52/DDI, P53/DDI, P54/DCK, P55/DMS: same as before reset * all other pins: input port mode HALT mode during same as before HALT mode Power-OnClear (POC) P05/DRST: DRST input with internal pull-down resistor P52/DDI, P54/DCK, P55/DMS: DDI, DCK, DMS inputs P53/DDO: DDO output all other pins: input port mode after IDLE 1, IDLE 2, STOP mode a) 130 during same as before power save mode: * Output signals are valid and output levels are remained. * Input signals with wake-up capabilitya are valid. * Input signals without wake-up capability are ignored. after same as before power save mode Inputs with wake-up capability: external interrupts (INTP0 to INTP11, NMI) and CAN0 receive data (CRXD0) User's Manual U18743EE1V2UM00 Pin Functions Chapter 2 2.8 Recommended Connection of unused Pins If a pin is not used, it is recommended to connect it as follows: Table 2-41 Recommended connection of unused pins Pin Recommended connection Port pins pins of port groups 0, 1, 3 to 5, 9 (except P05 of port group 0) * output pins: leave open * input pins: connect to EVDD or EVSS via a resistor P05 of port group 0 * output pins: leave open * input pins: connect to EVSS via a resistor pins of port groups 7 * output pins: leave open * input pins: connect to AVREF0 or AVSS via a resistor pins of port groups CM, CS, CT, DL * output pins: leave open * input pins: connect to BVDD or BVSS via a resistor Non-port pins AVREF0 connect to VDD FLMD0 connect to VSS REGC connect to regulator output stability capacity XT1 connect to VSS via a resistor XT2 leave open Not connect pins IC Note Connect directly to VSS via a resistor 1. When connecting the unused pins with a power supply or ground, it is recommended to connect the pins through a resistance of 1 to 10 K. 2. If the overall maximum output current exceeds its maximum value the output buffer can be damaged. We recommend the placement of a series resistor to prevent damage in case of accidentally enabled outputs. Refer to the absolute maximum rating parameter in the Electrical Target Specification. User's Manual U18743EE1V2UM00 131 Chapter 2 Pin Functions 2.9 Package Pins Assignment The following figures shows the location of pins in top view. Every pin is labelled with its pin number and all possible pin names. 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 P70/ANI0 P71/ANI1 P72/ANI2 P73/ANI3 P74/ANI4 P75/ANI5 P76/ANI6 P77/ANI7 P78/ANI8 P79/ANI9 PDL7 PDL6 PDL5/FLMD1 PDL4 PDL3 PDL2 2.9.1 V850ES/FE3-L package pins assignment 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 PD70F3610GB-GAH PD70F3611GB-GAH PD70F3612GB-GAH PD70F3613GB-GAH PD70F3614GB-GAH P05/INTP2/DRST P06/INTP3/CTXD0 P40/SIB0/KR0 P41/SOB0/KR1 P42/SCKB0/KR2 P30/TXDD0 P31/RXDD0/INTP7 P32/ASCKD0/TOAA01/TIAA00/TOAA00 P33/TIAA01/TOAA01/CTXD0 P34/TIAA10/TOAA10/CRXD0 P35/TIAA11/TOAA11 P50/KR0 P51/KR1 P52/KR2/DDI P53/KR3DDO EVSS 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 AVREF0 AVSS FLMD0 VDD REGC VSS X1 X2 RESET XT1 XT2 P00/TIAA31/TOAA31 P01/TIAA30/TOAA30 P02/NMI/TIAA40/TOAA40 P03/INTP0/ADTRG/TIAA41/TOAA41 P04/INTP1/CRXD0 Figure 2-59 132 V850ES/FE3-L package pin assignment User's Manual U18743EE1V2UM00 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 PDL1 PDL0 PCM1/CLKOUT PCM0 P915/INTP6/SCL00 P914/INTP5/SDA00 P913/INTP4/PCL P99/SCKB1 P98/SOB1 P97/SIB1/TIAA20/TOAA20 P96/TIAA21/TOAA21 P91/KR7/RXDD1 P90/KR6/TXDD1 P55/KR5/DMS P54/KR4/DCK EVDD Pin Functions Chapter 2 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 P70/ANI0 P71/ANI1 P72/ANI2 P73/ANI3 P74/ANI4 P75/ANI5 P76/ANI6 P77/ANI7 P78/ANI8 P79/ANI9 P710/ANI10 P711/ANI11 PDL11 PDL10 PDL9 PDL8 PDL7 PDL6 PDL5/FLMD1 PDL4 2.9.2 V850ES/FF3-L package pins assignment 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 PD70F3615GK-GAK PD70F3616GK-GAK PD70F3617GK-GAK PD70F3618GK-GAK PD70F3619GK-GAK 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 PDL3 PDL2 PDL1 PDL0 PCT6 PCT4 PCT1 PCT0 PCM3 PCM2 PCM1/CLKOUT PCM0 PCS1 PCS0 P915/INTP6/SCL00 P914/INTP5/SDA00 P913/INTP4/PCL P99/SCKB1 P98/SOB1 P97/SIB1/TIAA20/TOAA20 P42/SCKB0/KR2 P30/TXDD0 P31/RXDD0/INTP7 P32/ASCKD0/TOAA01/TIAA00/TOAA00 P33/TIAA01/TOAA01/CTXD0 P34/TIAA10/TOAA10/CRXD0 P35/TIAA11/TOAA11 P38 P39 EVSS EVDD P50/KR0 P51/KR1 P52/KR2/DDI P53/KR3/DDO P54/KR4/DCK P55/KR5/DMS P90/KR6/TXDD1 P91/KR7/RXDD1 P96/TIAA21/TOAA21 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 AVREF0 AVSS P00/TIAA31/TOAA31 P01/TIAA30/TOAA30 P02/NMI/TIAA40/TOAA40 P03/INTP0/ADTRG/TIAA41/TOAA41 P04/INTP1/CRXD0 FLMD0 VDD REGC VSS X1 X2 RESET XT1 XT2 P05/INTP2/DRST P06/INTP3/CTXD0 P40/SIB0/KR0 P41/SOB0/KR1 Figure 2-60 V850ES/FF3-L package pin assignment User's Manual U18743EE1V2UM00 133 Chapter 2 Pin Functions 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 P70/ANI0 P71/ANI1 P72/ANI2 P73/ANI3 P74/ANI4 P75/ANI5 P76/ANI6 P77/ANI7 P78/ANI8 P79/ANI9 P710/ANI10 P711/ANI11 P712/ANI12 P713/ANI13 P714/ANI14 P715/ANI15 PDL13 PDL12 PDL11 PDL10 PDL9 PDL8 PDL7 PDL6 PDL5/FLMD1 2.9.3 V850ES/FG3-L package pins assignment 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 PD70F3620GC-UEU PD70F3621GC-UEU PD70F3622GC-UEU P31/RXDD0/INTP7 P32/ASCKD0/TOAA01/TIAA00/TOAA00 P33/TIAA01/TOAA01/CTXD0 P34/TIAA10/TOAA10/CRXD0 P35/TIAA11/TOAA11 P36 P37 EVSS EVDD P38/TXDD2 P39/RXDD2/INTP8 P50/KR0 P51/KR1 P52/KR2/DDI P53/KR3/DDO P54/KR4/DCK P55/KR5/DMS P90/KR6/TXDD1 P91/KR7/RXDD1 P92 P93 P94 P95 P96/TIAA21/TOAA21 P97/SIB1/TIAA20/TOAA20 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 AVREF0 AVSS P10/INTP9 P11/INTP10 EVDD P00/TIAA31/TOAA31 P01/TIAA30/TOAA30 FLMD0 VDD REGC VSS X1 X2 RESET XT1 XT2 P02/NMI/TIAA40/TOAA40 P03/INTP0/ADTRG/TIAA41/TOAA41 P04/INTP1/CRXD0 P05/INTP2/DRST P06/INTP3/CTXD0 P40/SIB0/KR0 P41/SOB0/KR1 P42/SCKB0/KR2 P30/TXDD0 Figure 2-61 134 V850ES/FG3-L package pin assignment User's Manual U18743EE1V2UM00 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 PDL4 PDL3 PDL2 PDL1 PDL0 BVDD BVSS PCT6 PCT4 PCT1 PCT0 PCM3 PCM2 PCM1/CLKOUT PCM0 PCS1 PCS0 P915/INTP6/SCL00 P914/INTP5/SDA00 P913/INTP4/PCL P912 P911 P910 P99/SCKB1 P98/SOB1 Chapter 3 CPU System Functions This chapter describes the registers of the CPU, the operation modes, the address space and the memory areas. 3.1 Overview The CPU is founded on Harvard architecture and it supports a RISC instruction set. Basic instructions can be executed in one clock period. Optimized fivestage pipelining is supported. This improves instruction execution speed. In order to make the microcontroller ideal for use in digital control applications, a 16-bit hardware multiplier enables this CPU to support word/half-word multiply instructions, saturated multiply instructions, bit operation instructions, etc. Features summary The CPU has the following special features: * Memory space: - 64 MB linear program space - 4 GB linear data space * 32 general purpose registers * Internal 32-bit architecture * Five-stage pipeline * Efficient multiplication and division instructions * Saturation logic (saturated operation instructions) * Barrel shifter (32-bit shift in one clock cycle) * Instruction formats: long and short * Four types of bit manipulation instructions: set, clear, not, test User's Manual U18743EE1V2UM00 135 Chapter 3 CPU System Functions 3.1.1 Description The figure below shows a block diagram of the microcontroller, focusing on the CPU and modules that interact with the CPU directly. Table 3-1 lists the bus types. CPU RCU interface System controller Instruction queue V F B Multiplier (16 x 16 ? 32) Program counter General-purpose registers Barrel shifter System registers ALU Bus control unit (BCU) V D B V S B Interrupt control unit (INTC) Bus bridge (BBR) Standby control unit (STBC) NPB Figure 3-1 CPU system The shaded busses are used for accessing the configuration registers of the concerned modules. Table 3-1 136 Bus types Bus type Function NPB - Peripheral bus Bus interface to the peripherals (internal bus). VSB - System bus Bus interface to the Memory Controller for access to the NPB bus bridge BBR. VFB - Fetch bus Interface to the internal ROM (mask ROM or code flash). VDB - Data bus Interface to the internal RAM. User's Manual U18743EE1V2UM00 CPU System Functions Chapter 3 3.2 CPU Register Set There are two categories of registers: * General purpose registers * System registers All registers are 32-bit registers. An overview is given in the figure below. For details, refer to V850ES User's Manual Architecture. 31 r0 0 31 0 (Zero Register) EIPC (Status Saving Register during interrupt) r1 (Reserved for Assembler) EIPSW (Status Saving Register during interrupt) r2 (Interrupt Stack Pointer) r3 (Stack Pointer (SP)) FEPC (Status Saving Register during NMI) r4 (Global Pointer (GP)) FEPSW (Status Saving Register during NMI) r5 (Text Pointer (TP)) ECR (Interrupt/Execution Source Register) PSW (Program Status Word) CTPC (Status Saving Register during CALLT execution) r6 r7 r8 r9 r1 0 r1 1 CTPSW (Status Saving Register during CALLT execution) r1 2 r1 3 DBPC r1 4 (Status Saving Register during exception/debug trap) DBPSW (Status Saving Register during exception/debug trap) r1 5 r1 6 r1 7 CTBP (CALLT Base Pointer) PC (Program Counter) r1 8 r1 9 r2 0 r2 1 r2 2 r2 3 r2 4 r2 5 r2 6 r2 7 r2 8 r2 9 r3 0 (Element Pointer (EP)) r3 1 (Link Pointer (LP)) Figure 3-2 CPU register set Some registers are write protected. That means, writing to those registers is protected by a special sequence of instructions. Refer to "Write Protected Registers" on page 155 for more details. User's Manual U18743EE1V2UM00 137 Chapter 3 CPU System Functions 3.2.1 General purpose registers (r0 to r31) Each of the 32 general purpose registers can be used as a data variable or address variable. However, the registers r0, r1, r3 to r5, r30, and r31 may implicitly be used by the assembler/compiler (see table Table 3-2). For details refer to the documentation of your assembler/compiler. Table 3-2 General purpose registers Register name Usage Operation r0 Zero register Always holds 0. It is used for operations using 0 and offset 0 addressing.a r1 Assembler-reserved register Used for 32-bit direct addressing.b r2 User address/data variable register r3 Stack pointer Used to generate stack frame when function is called.b r4 Global pointer Used to access global variable in data area.b r5 Text pointer Used to indicate the start of the text area (where program code is located).b r6 to r29 User address/data variable registers r30 Element pointer Base pointer when memory is accessed by means of instructions SLD (short format load) and SST (short format store).a r31 Link pointer Used when calling a function.b a) b) Caution 138 Registers r0 and r30 are used by dedicated instructions. Registers r1, r3, r4, r5, and r31 may be used by the assembler/compiler. Before using registers r1, r3 to r5, r30, and r31, their contents must be saved so that they are not lost. The contents must be restored to the registers after the registers have been used. User's Manual U18743EE1V2UM00 CPU System Functions Chapter 3 3.2.2 System register set System registers control the status of the CPU and hold interrupt information. Additionally, the program counter holds the instruction address during program execution. To read/write the system registers, use instructions LDSR (load to system register) or STSR (store contents of system register), respectively, with a specific system register number (regID) indicated below. The program counter states an exception. It cannot be accessed via LDSR or STSR instructions. No regID is allocated to the program counter. Example STSR 0, r2 Stores the contents of system register 0 (EIPC) in general purpose register r2. System register numbers Table 3-3 The table below gives an overview of all system registers and their system register number (regID). It shows whether a load/store instruction is allowed (x) for the register or not (-). System register numbers regID System register name Shortcut 0 Status saving register during interrupt (stores contents of PC) EIPC 1 Status saving register during interrupt (stores contents of PSW) EIPSW 2 Status saving register during non-maskable interrupts (stores contents of PC) FEPC 3 Status saving register during non-maskable interrupts (stores contents of PSW) FEPSW 4 Interrupt source register 5 Program status word 6 to 15 Reserved (operations that access these register numbers cannot be guaranteed). 16 Status saving register during CALLT execution (stores contents of PC) CTPC 17 Status saving register during CALLT execution (stores contents of PSW) CTPSW 18 Status saving register during exception/debug trap (stores contents of PC) 19 Operand specification LDSR STSR x x x x x x x x ECR - x PSW x x - - x x x x DBPC xa x Status saving register during exception/debug trap (stores contents of PSW) DBPSW xa x 20 CALLT base pointer CTBP x x 21 to 31 Reserved (operations that access these register numbers cannot be guaranteed). - - a) Reading from this register is only enabled between a DBTRAP exception (exception handler address 0000 0060H) and the exception handler terminating DBRET instruction. DBTRAP exceptions are generated upon ILGOP detections (refer to "Interrupt Controller (INTC)" on page 221). User's Manual U18743EE1V2UM00 139 Chapter 3 CPU System Functions (1) PC - Program counter The program counter holds the instruction address during program execution. The lower 26 bits are valid, and bits 31 to 26 are fixed to 0. If a carry occurs from bit 25 to 26, it is ignored. Branching to an odd address cannot be performed. Bit 0 is fixed to 0. Access Initial Value This register can not be accessed by any instruction. 0000 0000H. The program counter is cleared by any reset. 31 26 25 1 fixed to 0 (2) instruction address during execution 0 0 EIPC, FEPC, DBPC, CTPC - PC saving registers The PC saving registers save the contents of the program counter for different occasions, see Table 3-4. When one of the occasions listed in Table 3-4 occurs, except for some instructions, the address of the instruction following the one being executed is saved to the saving registers. For more details refer to Table 3-9 on page 144 and to the "Interrupt Controller (INTC)" on page 221. All PC saving registers are built up as the PC, with the initial value 0xxx xxxxH (x = undefined). Table 3-4 PC saving registers Register Shortcut Saves contents of PC in case of Status saving register during interrupt EIPC * software exception * maskable interrupt Status saving register during non-maskable interrupts FEPC * non-maskable interrupt Status saving register during exception/debug trap DBPCa * * * * Status saving register during CALLT execution CTPC * execution of CALLT instruction a) Note Caution 140 exception trap debug trap debug break during a single-step operation Reading from this register is only enabled between a DBTRAP exception (exception handler address 0000 0060H) and the exception handler terminating DBRET instruction. DBTRAP exceptions are generated upon ILGOP detections (refer to "Interrupt Controller (INTC)" on page 221). When multiple interrupt servicing is enabled, the contents of EIPC or FEPC must be saved by program--because only one PC saving register for maskable interrupts and non-maskable interrupts is provided, respectively. When setting the value of any of the PC saving registers, use even values (bit 0 = 0). If bit 0 is set to 1, the setting of this bit is ignored. This is because bit 0 of the program counter is fixed to 0. User's Manual U18743EE1V2UM00 CPU System Functions (3) Chapter 3 PSW - Program status word The 32-bit program status word is a collection of flags that indicates the status of the program (result of instruction execution) and the status of the CPU. If the bits in the register are modified by the LDSR instruction, the PSW will take on the new value immediately after the LDSR instruction has been executed. Initial Value 0000 0020H. The program status is initialized by any reset. 31 8 fixed to 0 R R Table 3-5 Bit position 7 6 5 7 6 5 4 3 2 1 0 NP EP ID SAT CY OV S Z R/W R/W R/W R/W R/W R/W R/W R/W PSW register contents (1/2) Flag Function NP Indicates that non-maskable interrupt (NMI) servicing is in progress. This flag is set when NMI request is acknowledged, and multiple interrupt servicing is disabled. 0: NMI servicing is not in progress. 1: NMI servicing is in progress. EP Indicates that exception processing is in progress. This flag is set when an exception occurs. Even when this bit is set, interrupt requests can be acknowledged. 0: Exception processing is not in progress. 1: Exception processing is in progress. ID Indicates whether a maskable interrupt request can be acknowledged. 0: Interrupts enabled. 1: Interrupts disabled. Note: Setting this flag will disable interrupt requests even while the LDSR instruction is being executed. For saturated operation processing instructions only: Indicates that the operation result is saturated due to overflow. 0: Not saturated. 1: Saturated. 4 SATa Note: 1. This is a cumulative flag: The bit is not automatically cleared if subsequent instructions lead to not saturated results. To clear this bit, use the LDSR instruction to set PSW.SAT = 0. 2. In a general arithmetic operation this bit is neglected. It is neither set nor cleared. 3 CY Carry/borrow flag. Indicates whether a carry or borrow occurred as a result of the operation. 0: Carry or borrow did not occur 1: Carry or borrow occurred. User's Manual U18743EE1V2UM00 141 Chapter 3 CPU System Functions Table 3-5 Bit position Flag a 2 OV 1 a 0 a) PSW register contents (2/2) Function Overflow flag. Indicates whether an overflow occurred as a result of the operation. 0: Overflow did not occur. 1: Overflow occurred. S Sign flag. Indicates whether the result of the operation is negative. 0: Result is positive or zero. 1: Result is negative. Z Zero flag. Indicates whether the result of the operation is zero. 0: Result is not zero. 1: Result is zero. In the case of saturate instructions, the SAT, S, and OV flags will be set according to the result of the operation as shown in the table below. Note that the SAT flag is set only when the OV flag has been set during a saturated operation. Saturated operation instructions Table 3-6 The following table shows the setting of flags PWS.SAT, PWS.OV, and PWS.S, depending on the status of the operation result. Saturation-processed operation result SAT OV S Maximum positive value exceeded 1 1 0 7FFF FFFFH Maximum negative value exceeded 1 1 1 8000 0000H xa 0 0 Operation result itself Positive (maximum not exceeded) Negative (maximum not exceeded) a) 142 Flag status Saturation-processed operation result Status of operation result Retains the value before operation. User's Manual U18743EE1V2UM00 1 CPU System Functions (4) Chapter 3 EIPSW, FEPSW, DBPSW, CTPSWPSW saving registers The PSW saving registers save the contents of the program status word for different occasions, see Table 3-4. When one of the occasions listed in Table 3-4 occurs, the current value of the PSW is saved to the saving registers. All PSW saving registers are built up as the PSW, with the initial value 0000 0xxxH (x = undefined). Table 3-7 PSW saving registers Register Shortcut Saves contents of PSW in case of Status saving register during interrupt EIPSW * software exception * maskable interrupt Status saving register during non-maskable interrupts FEPSW * non-maskable interrupt Status saving register during exception/debug trap DBPSWa * * * * Status saving register during CALLT execution CTPSW a) exception trap debug trap debug break during a single-step operation * execution of CALLT instruction Reading from this register is only enabled between a DBTRAP exception (exception handler address 0000 0060H) and the exception handler terminating DBRET instruction. DBTRAP exceptions are generated upon ILGOP detections (refer to "Interrupt Controller (INTC)" on page 221). Note When multiple interrupt servicing is enabled, the contents of EIPSW or FEPSW must be saved by program--because only one PSW saving register for maskable interrupts and non-maskable interrupts is provided, respectively. Caution Bits 31 to 26 of EIPC and bits 31 to 12 and 10 to 8 of EIPSW are reserved for future function expansion (fixed to 0).When setting the value of EIPC, FEPC, or CTPC, use even values (bit 0 = 0). If bit 0 is set to 1, the setting of this bit is ignored. This is because bit 0 of the program counter is fixed to 0. User's Manual U18743EE1V2UM00 143 Chapter 3 CPU System Functions (5) ECR - Interrupt/exception source register The 32-bit ECR register displays the exception codes if an exception or an interrupt has occurred. With the exception code, the interrupt/exception source can be identified. For a list of interrupts/exceptions and corresponding exception codes, see Table 3-9 on page 144. Initial Value 0000 0000H. This register is cleared by any reset. 31 26 25 FECC Table 3-8 0 EICC ECR register contents Bit position Bit name 31 to 16 FECC Exception code of non-maskable interrupt (NMI) 15 to 0 EICC Exception code of exception or maskable interrupts Function The following table lists the exception codes. Table 3-9 Interrupt/execution codes Interrupt/Exception Source Classification Exception Code Handler Address Value restored to EIPC/FEPC Name Trigger Non-maskable interrupts (NMI) NMI0 input Interrupt 0010H 0000 0010H next PC (see Note) NMI1 input Interrupt 0020H 0000 0020H next PC (see Note) NMI2 input Interrupt 0030H 0000 0030H next PC (see Note) Maskable interrupt refer to "Interrupt Controller (INTC)" on page 221 Interrupt refer to "Interrupt Controller (INTC)" on page 221 * higher 16 bits: 0000H * lower 16 bits: exception code next PC (see Note) Software exception TRAP0n (n = 0 to FH) TRAP Exception instruction 004nH 0000 0040H next PC TRAP1n (n = 0 to FH) TRAP Exception instruction 005nH 0000 0050H next PC Exception trap (ILGOP) Illegal Exception instruction code 0060H 0000 0060H next PC Debug trap DBTRAP Exception instruction 0060H 0000 0060H next PC 144 User's Manual U18743EE1V2UM00 CPU System Functions Chapter 3 If an interrupt (maskable or non-maskable) is acknowledged during instruction execution, generally, the address of the instruction following the one being executed is saved to the saving registers, except when an interrupt is acknowledged during execution of one of the following instructions: * load instructions (SLD.B, SLD.BU, SLD.H, SLD.HU, SLD.W) * divide instructions (DIV, DIVH, DIVU, DIVHU) * PREPARE, DISPOSE instruction (only if an interrupt is generated before the stack pointer is updated) In this case, the address of the interrupted instruction is restored to the EIPC or FEPC, respectively. Execution is stopped, and after the completion of interrupt servicing the execution is resumed. (6) CTBP - CALLT base pointer The 32-bit CALLT base pointer is used with the CALLT instruction. The register content is used as a base address to generate both a 32-bit table entry address and a 32-bit target address. Initial Value 31 a) 30 29 28 Undefined 27 26 25 1 0 0 0 0 0 0 0 base address 0 Ra Ra Ra Ra Ra Ra R/W R These bits may be written, but write is ignored. User's Manual U18743EE1V2UM00 145 Chapter 3 CPU System Functions 3.3 Operation Modes This section describes the operation modes of the CPU and how the modes are specified. The following operation modes are available: * Normal operation mode * Flash programming mode After reset release, the microcontroller starts to fetch instructions from an internal boot ROM which contains the internal firmware. The firmware checks the pins FLMD0 and FLMD1 (PDL5) to set the operation mode after reset release according to Table 3-10: Table 3-10 Selection of operation modes Pins Note Operation Mode FLMD0 FLMD1 (PDL5) 0 X Normal operation mode (fetch from code flash) 1 0 Flash programming mode 1 Setting prohibited The FLMD1 pin function is shared with the PDL5 pin. 3.3.1 Normal operation mode In normal operation mode, the internal code flash memory is not reprogrammed. After reset release, the firmware acquires the user's reset vector from the code flash memory. The reset vector contains the start address of the user's program code. The firmware branches to that address. Program execution is started. 3.3.2 Flash programming mode (flash memory devices only) In flash programming mode, the internal code flash memory is erased and re-programmed. After reset release, the firmware initiates loading of the user's program code from the external flash programmer and programs the code flash memory. After detaching the external flash programmer, the microcontroller can be started up with the new user's program in normal operation mode. For more information see section "Flash Memory" on page 259. 3.3.3 On-Chip debug mode By connecting an N-Wire emulator, on-chip debugging can be executed. The N-Wire emulator is connected through JTAG type signals. In On-Chip debug mode user's code can be programmed into the flash. 146 User's Manual U18743EE1V2UM00 CPU System Functions Chapter 3 Afterwards the software can be evaluated using breakpoints and the user resources (such as memory and I/O can be read or written. For more information see Chapter 23 on page 723. 3.4 Address Space In the following sections, the address space of the CPU is explained. Size and addresses of CPU address space and physical address space are explained. The address range of data space and program space together with their wraparound properties are presented. 3.4.1 CPU address space and physical address space The CPU supports the following address space: * 4 GB CPU address space With the 32-bit general purpose registers, addresses for a 4 GB memory can be generated. This is the maximum address space supported by the CPU. * 64 MB physical address space The CPU provides 64 MB physical address space. That means that a maximum of 64 MB internal memory can be accessed. Any 32-bit address is translated to its corresponding physical address by ignoring bits 31 to 26 of the address. Thus, 64 addresses point to the same physical memory address. In other words, data at the physical address 0000 0000H can additionally be accessed by addresses 0400 0000H, 0800 0000H, ..., F800 0000H, or FC00 0000H. User's Manual U18743EE1V2UM00 147 Chapter 3 CPU System Functions The 64 MB physical address space is seen as 64 images in the 4 GB CPU address space: CPU address space FFFF FFFFH Image FC00 0000H FBFF FFFFH Physical address space Fixed peripheral I/O Image Internal RAM use prohibited Programmable peripheral I/O F800 0000H F7FF FFFFH Image 0800 0000H 07FF FFFFH x3FF F000H x3FF x000H note x3FF 0000H x3FE C000H use prohibited Internal Flash/ROM Image x3FF FFFFH x000 0000H Address bits A[31:26] = x 0400 0000H 03FF FFFFH Image 0000 0000H Figure 3-3 Note 148 Images in the CPU address space The start address of the internal RAM area depends on the product derivative. See "Internal RAM area" on page 151 for details. User's Manual U18743EE1V2UM00 CPU System Functions Chapter 3 3.4.2 Program and data space The CPU allows the following assignment of data and instructions to the CPU address space: * 4 GB as data space The entire CPU address space can be used for operand addresses. * 64 MB as program space Only the lower 64 MB of the CPU address space can be used for instruction addresses. When an instruction address for a branch instruction is calculated and moved to the program counter (PC), then bits 31 to 26 are set to zero. Figure 3-4 shows the assignment of the CPU address space to data and program space. CPU address space FFFF FFFFH Data area (4 GB linear) 0400 0000H 03FF FFFFH Program area (64 MB linear) 0000 0000H Figure 3-4 CPU address space User's Manual U18743EE1V2UM00 149 Chapter 3 CPU System Functions (1) Wrap-around of data space If an operand address calculation exceeds 32 bits, only the lower 32 bits of the result are considered. Therefore, the addresses 0000 0000H and FFFF FFFFH are contiguous addresses. This results in a wrap-around of the data space: FFFF FFFEH Data space FFFF FFFFH (+) direction 0000 0000H (-) direction 0000 0001H Data space Figure 3-5 (2) Wrap-around of data space Wrap-around of program space If an instruction address calculation exceeds 26 bits, only the lower 26 bits of the result are considered. Therefore, the addresses 0000 0000H and 03FF FFFFH are contiguous addresses. This results in a wrap-around of the program space: 03FF FFFEH Program space 03FF FFFFH (+) direction 0000 0000H (-) direction 0000 0001H Program space Figure 3-6 Caution 150 Wrap-around of program space No instruction can be fetched from the 4 KB area of 03FF F000H to 03FF FFFFH because this area is defined as peripheral I/O area. Therefore, do not execute any branch to this area. User's Manual U18743EE1V2UM00 CPU System Functions Chapter 3 3.5 Memory In the following sections, the memory of the CPU is introduced. Specific memory areas are described and a recommendation for the usage of the address space is given. 3.5.1 Memory areas The internal memory of the CPU provides several areas: * Internal code flash area * Internal RAM area * Internal fixed peripheral I/O area * Programmable peripheral I/O area The areas are briefly described below. (1) Internal code flash area Table 3-11 shows the size and address range of internal code flash area. Table 3-11 Internal code flash areas V850ES/Fx3-L Product Device V850ES/FE3-L PD70F3610 64 KB 0000 0000H to 0000 FFFFH PD70F3611 96 KB 0000 0000H to 0001 7FFFH PD70F3612 128 KB 0000 0000H to 0001 FFFFH PD70F3613 192 KB 0000 0000H to 0002 FFFFH PD70F3614 256 KB 0000 0000H to 0003 FFFFH PD70F3615 64 KB 0000 0000H to 0000 FFFFH PD70F3616 96 KB 0000 0000H to 0001 7FFFH PD70F3617 128 KB 0000 0000H to 0001 FFFFH PD70F3618 192 KB 0000 0000H to 0002 FFFFH PD70F3619 256 KB 0000 0000H to 0003 FFFFH PD70F3620 128 KB 0000 0000H to 0001 FFFFH PD70F3621 192 KB 0000 0000H to 0002 FFFFH PD70F3622 256 KB 0000 0000H to 0003 FFFFH V850ES/FF3-L V850ES/FG3-L (2) Code flash size Address range Internal RAM area Table 3-12 shows the size and address range of internal RAM area. User's Manual U18743EE1V2UM00 151 Chapter 3 CPU System Functions Table 3-12 Internal RAM areas V850ES/Fx3-L Product Device RAM size Address range V850ES/FE3-L PD70F3610 6 KB 03FF D800H - 03FF EFFFH PD70F3611 6 KB 03FF D800H - 03FF EFFFH PD70F3612 8 KB 03FF D000H - 03FF EFFFH PD70F3613 12 KB 03FF C000H - 03FF EFFFH PD70F3614 16 KB 03FF B000H - 03FF EFFFH PD70F3615 6 KB 03FF D800H - 03FF EFFFH PD70F3616 6 KB 03FF D800H - 03FF EFFFH PD70F3617 8 KB 03FF D000H - 03FF EFFFH PD70F3618 12 KB 03FF C000H - 03FF EFFFH PD70F3619 16 KB 03FF B000H - 03FF EFFFH PD70F3620 8 KB 03FF D000H - 03FF EFFFH PD70F3621 12 KB 03FF C000H - 03FF EFFFH PD70F3622 16 KB 03FF B000H - 03FF EFFFH V850ES/FF3-L V850ES/FG3-L Note that the internal firmware, which is processed after reset, uses some RAM (refer to "Reset" on page 705). (3) Fixed peripheral I/O area The 4 KB area between addresses 03FF F000H and 03FF FFFFH is provided as the internal fixed peripheral I/O area. Accesses to these addresses are passed over to the NPB bus (internal bus). The following registers are memory-mapped to this area: * All registers of peripheral functions * Registers of timers * Configuration registers of interrupt and Memory Controllers * Configuration registers of the clock controller For a list of all peripheral I/O registers, see "Special Function Registers" on page 737. Note 1. Because the physical address space covers 64 MB, the address bits A[31:26] are not considered. Thus, this 4 KB address space can also be addressed via the area FFFF 0000H to FFFF FFFFH. This has the advantage that the area can be indirectly addressed by an offset and the zero base r0. Therefore, in this manual, all addresses of peripheral I/O registers in the 4 KB peripheral I/O area are given in the range FFFF F000H to FFFF FFFFH instead of 03FF F000H to 03FF FFFFH. 2. The fixed peripheral I/O area is mirrored to the upper 4 KB of the programmable peripheral I/O area PPA. If data is written to one area, it appears also in the other area. 3. Program fetches cannot be executed from any peripheral I/O area. 4. Word registers, that means 32-bit registers, are accessed in two half word accesses. The lower two address bits are ignored. 152 User's Manual U18743EE1V2UM00 CPU System Functions Chapter 3 5. For registers in which byte access is possible, if half word access is executed: * During read operation: The higher 8 bits become undefined. * During write operation: The lower 8 bits of data are written to the register. Caution (4) 1. Addresses that are not defined as registers are reserved for future expansion. If these addresses are accessed, the operation is undefined and not guaranteed. Programmable peripheral I/O area The 16 KB area between addresses 03FE C000H and 03FE EFFFH is provided as a programmable peripheral I/O area (PPA). Within the microcontroller, the usage and address range of the PPA are not configurable. The CAN modules registers and message buffers are allocated to the PPA. Refer to "CAN module register and message buffer addresses" on page 553 for information on how to calculate the register and message buffer addresses of the CAN modules. The base address of the PPA is specified by the peripheral area selection control register (BPC). * For the microcontroller, the base address of the PPA is fixed to 03FE C000H. Thus writing to BPC.PA[13:0] does not change the PPA base address. Nevertheless the PPA must be enabled by setting BPC.PA15 = 1. * For the emulation tool, the PPA has to be enabled and the base address has to be set up by writing 8FFBH to the BPC register. To make software suitable for both microcontroller and emulation tool, it is recommended to include the set up of the PPA with BPC = 8FFBH in the software. User's Manual U18743EE1V2UM00 153 Chapter 3 CPU System Functions 3.5.2 Recommended use of data address space When accessing operand data in the data space, one register has to be used for address generation. This register is called pointer register. With relative addressing, an instruction can access operand data at all addresses that lie in the range of 32 KB relative to the address in the pointer register. By this offset addressing method load/store instructions can be accommodated in a single 32-bit instruction word, resulting in faster program execution and smaller code size. To enhance the efficiency of using the pointer in consideration of the memory map, the following is recommended: For efficient use of the relative addressing feature, the data segments should be located in the address range FFFF F800H to 0000 0000H and 0000 0000H to 0000 7FFFH. The peripheral I/O registers and the internal RAM is aligned to the upper bound, thus the registers and a part of the RAM can be addressed via relative addressing, with base address 0 (r0). It is recommended to locate code flash memory data segments in the area up to 0000 7FFFH, so access to these constant data can utilize also relative addressing. Use the r0 register as pointer register for operand addressing. Since the r0 register is fixed to zero by hardware, it can be used as a pointer register and, at the same time, for any other purposes, where a zero register is required. Thus, no other general purpose register has to be reserved as pointer register. 0000 7FFFH Internal flash area (1 MB) +32 KB (r0=)0000 0000H FFFF F000H FFFF EFFFH Fixed peripheral I/O area (4 KB) -32 KB Internal RAM area (28 KB) FFFF 8000H FFFF 7FFFH Internal RAM area (32 KB) FFFF 0000H Figure 3-7 154 Example application of wrap-around User's Manual U18743EE1V2UM00 CPU System Functions Chapter 3 3.6 Write Protected Registers Write protected registers are protected from inadvertent write access due to erroneous program execution, etc. Write access to a write protected register is only given immediately after writing to a corresponding write enable register. For a write access to the write protected registers you have to use the following instructions: 1. Store instruction (ST/SST instruction) 2. Bit operation instruction (SET1/CLR1/NOT1 instruction) Incorrect store operations can be checked by a flag of the system status register (SYS). When reading write protected registers, no special sequence is required. The following table gives an overview of the write protected registers and their corresponding write enable registers. Table 3-13 Overview of write protected registers Write protected register Shortcut Processor clock control register PCC Main system clock mode register MCM Clock Monitor mode register CLM Power save control register PSC Reset source flag register RESF Internal RAM data status register RAMS Low-voltage detection register LVIM On-chip debug mode register OCDM Example Corresponding write Shortcut For details see enable register "Clock Generator" on page 179 Command register PRCMD "Reset" on page 705 "Low-Voltage Detector" on page 713 "On-Chip Debug Unit" on page 723 Enable Clock Monitor The following example shows how to write to the write protected register CLM. The example enables the Clock Monitor. do { _PRERR = 0; DI(); PRCMD = 0x5A; CLM = 0x01; EI(); } while (_PRERR != 0) Note 1. Make sure that the compiler generates two consecutive assembler "store" instructions to PRCMD and CLM from the associated C statements. 2. Special care must be taken when writing to registers PSC and PRCMD. Please refer to "Clock Generator" on page 179 for details. 3. Any value can be written to the PRMCD register. User's Manual U18743EE1V2UM00 155 Chapter 3 CPU System Functions Since any action between writing to a write enable register and writing to a protected register destroys this sequence, the effects of interrupts have to be considered: * Interrupts: In order to prevent any maskable interrupt to be acknowledged between the two write instructions in question, shield this sequence by DI-EI (disable interrupt--enable interrupt). However, any non-maskable interrupt can still be acknowledged. 156 User's Manual U18743EE1V2UM00 CPU System Functions Chapter 3 3.6.1 Write protection control registers The following section describes the registers that control access to write protected registers. (1) PRCMD - Command register The 8-bit PRCMD register protects other registers from inadvertent write access, so that the system does not stop in case of a program hang-up. After writing to the PRCMD register, you are permitted to write once to one of the protected registers. This must be done immediately after writing to the PRCMD register. After the second write action all protected registers are writelocked again. Read accesses to any register are permitted between write access to the PRCMD and the protected register. Any value can be written to the PRCMD register. Nevertheless, writing '00H' or the value to be stored to the protected register in the next instruction minimizes the use of CPU register and the program size. Access Address Initial Value This register can only be written in 8-bit units. FFFF F1FCH. The contents of this register is undefined. 7 6 5 4 3 2 1 0 X X X X X X X X W W W W W W W W An invalid write attempt to one of write protected registers sets the error flag SYS.PRERR. (2) SYS - System register The 8-bit SYS register indicates the status of a write attempt to a write protected register. Access Address Initial Value This register can be read/written in 8-bit or 1-bit units. FFFF F802H. 00H. This register is cleared by any reset. 7 Table 3-14 6 5 4 3 2 1 0 0 0 0 0 0 0 0 PRERR R R R R R R R R/W SYS register contents Bit position 0 Bit name PRERR User's Manual U18743EE1V2UM00 Function Write error status: 0: Write access was successful. 1: Write access failed. You can clear this register by writing 0 to it. Setting this register to 1 by software is not possible. 157 Chapter 3 158 CPU System Functions User's Manual U18743EE1V2UM00 Chapter 4 Clock Generator The Clock Generator provides the clock signals needed by the CPU and the on-chip peripherals. 4.1 Overview The Clock Generator can generate the required clock signals from the following sources: * Main oscillator--a built-in oscillator that requires an external crystal with a frequency between 4 MHz and 16 MHz * Sub oscillator--a built-in oscillator that requires an external crystal (32,768 KHz) or an external RC resonator (20 KHz) * Low-frequency internal oscillator--an internal oscillator without external components and a nominal frequency of 240 KHz * High-frequency internal oscillator--an internal oscillator without external components and a nominal frequency of 8 MHz Features summary Special features of the Clock Generator are: * Choice of oscillators to reduce power consumption in stand-by mode * PLL synthesizer for the main oscillator: - In clock-through mode: 4 MHz to 16 MHz main system clock fXX - In PLL (Phase Locked Loop) mode main system clock fXX: - 8 MHz to 20 MHz with fixed frequency from PLL * Sub oscillator can be crystal controlled (fXT) * Two internal internal oscillators (fRL = 240 KHz and fRH = 8 MHz) * Internal main system clock generation: - fXX, fXX/2, fXX/4, fXX/8, fXX/16, fXX/32, fXT, fRL, fRH - Subclock mode: fXT or fRL selectable by an option byte in the code flash memory * Peripheral clock generation - fXP1 to fXP1 / 1024 - fXP1 = fXX or fXP1 = fXX /2 selectable by an option byte * Clock output function (CLKOUT pin) * Programmable clock output function (PCL pin) * Individual clock source selection for CPU and groups of peripherals * Specific power save modes * Vital system registers are write-protected by a special write sequence * Direct main oscillator clock feed-through for Watch Timer, Watchdog Timer, CSIB0, and CAN support * Clock Monitor for main oscillator User's Manual U18743EE1V2UM00 159 Chapter 4 Clock Generator 4.1.1 Description The Clock Generator is built up as illustrated in the following figure. OB_7A.STOPXTAL OB_7A.STOPRCZ PCC.FRC XT1 XT2 Xtal SubOSC fXT 0 1/2 fXT 1 WT, TMM0, TAA1, TAA3 RC 240 KHz internal oscillator fRL 1/8 0 fSC OB_7B.SUBCLK X1 X2 OB_7B.PLLI[1:0] fX MainOSC OB_7B.PLLO PLLCTL.PLLON fPLLO fPLLI Divider selector Clock Monitor IDLE1,2 mode PLL(x8) 0 1/2 1 fPLL 1 IDLE control IDLE2 mode PCC.MCK MainOSC stop control 1 fxx PCC.CK[2:0] Prescaler2 CLKOUT fXX/32 0 fXX/8 STOP mode MCM.MCM0 RCM.HRSTOP PCL PLLCTL.SELPLL fXX/4 8 MHz internal oscillator stop control 8 MHz internal oscillator fSC fXX/16 0 fXX/2 Selector PCC.MFRC fRL fVBCLK 0 1/2 PCLM.PCK[1:0] Divider selector fPCL IDLE2 mode fXP1 HALT fCPU control 0 HALT mode fXP1 to fXP1/1024 Prescaler1 Peripheral clocks 1 SELCNTx.ISELxx fXP1 0 1/2 CPU core clock PCC.CK3 OB_7B.PRSI IDLE control CPU system clock 1 fXX fRH WDT2, TMM0 control 1 RCM.RSTOP fRL/8 IDLE fXP2 fXP2 UARTDn, TAAn, MLM 0 1 1 1/8 fXP1/512 0 fRH/8 1 TMM0 SELCNT0.ISEL07 fXP1 IDLE fXC control 0 CANn 1 SELCNTx.ISELxx PRSM0, PRSCM0 registers IDLE1,2 mode Prescaler3 1/128 fBRG fX/128 WT, CSIB0 WDT2 Note: OB_7A.bitname and OB7B.bitname describe control bits of option byte 007AH and 007BH Figure 4-1 Block diagram of the Clock Generator The left-hand side of the figure shows how the four oscillators can be connected to the CPU and peripheral modules. Software-controlled selectors allow you to specify the signal paths. MainOSC The main oscillator (MainOSC) oscillates at frequencies fX = 4 MHz to 16 MHz. After reset release, the main oscillator is stopped.Starting the oscillation must be set via software. The main oscillator is equipped with a stop control. Oscillation of the main clock oscillator is stopped in the STOP mode or controlled by the PCC register. SubOSC 240 KHz internal oscillator 160 The sub oscillator (SubOSC) oscillates at a frequency fXT of 32.768 KHz (crystal connected) or typically 20 KHz with an external RC circuit. The low speed internal oscillator generates a clock fRL with a frequency of 240 KHz typically. The oscillation can be stopped by means of the RCM register. The oscillation cannot be stopped, if this is disabled by option byte 007AH. User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 8 MHz internal oscillator The high speed internal oscillator generates a clock fRH with a frequency of typically 8 MHz. After reset release, the 8 MHz internal oscillator is activated. The high speed internal oscillator is equipped with a stop control. The oscillation can be stopped by means of the RCM register. Main system clock fxx The main system clock fxx can be derived from different sources: * Clock-through mode: main system clock fXX derived from MainOSC fX or internal oscillator fRH. * PLL mode, main system clock fXX derived from fPLLO (PLL output). These modes can be selected by the bit PLLCTL.SELPLL. PLL The PLL circuit generates the base frequency fPLL, which can be used as the main system clock fxx. Input clock to the PLL the MainOSC fx. The PLL is preceded by a frequency divider. The input of the PLL (fPLLI) can be set to fX, fX/2, or fX/4. The divider is set through an option byte in the code flash memory. The phase-locked loop circuit (PLL) multiplies the MainOSC clock fx or a fraction of it by eight. Its input clock is called fPLLI, its output is fPLLO. The PLL is started or stopped by PLLCTL.PLLON. For details on the PLL see also "Controlling the PLL" on page 215. (1) System and CPU clocks The CPU system is clocked by two clocks: * fVBCLK supplies all remaining parts of the CPU system, like BCU, MEMC, INTC. * fCPU is derived from fVBCLK supplies the CPU core and is subject to HALT mode control. Clock source for both clocks can be the output of the PLL or any of the oscillators. The following table gives an overview of the available CPU clock sources. Table 4-1 Clock sources for the CPU Clock source Frequency Description 8 MHz internal oscillator ~8 MHz Default clock source after reset release. 240 KHz internal oscillator ~240 KHz Default clock source if MainOSC has stopped. SubOSC 32 KHz or 20 KHz Selectable as clock source. MainOSC 4 to 16 MHz CPU system clocks in clock-through mode PLL up to 20 MHz For maximum performance User's Manual U18743EE1V2UM00 161 Chapter 4 Clock Generator The clock sources MainOSC, PLL and 8 MHz internal oscillator can generate the master clock fXX. This clock forms the input to Prescaler2. Prescaler2 can divide the master clock fXX by 1, 2, 4, 8, 16 or 32. Its operation is set in the PCC register. Prescaler2, the SubOSC, or the 240 KHz internal oscillator can generate the CPU core clock (fCPU) and the CPU system clock (fVBCLK). The only difference between fVBCLK and fCPU is that the latter can be stopped in HALT mode. fVBCLK is the clock supplied to the INTC, ROM, and RAM blocks. It is directly available at the CLKOUT pin. (2) Peripheral clocks The middle and right-hand side of Figure 4-1 on page 160 shows how the clocks for the peripheral modules are generated and distributed. Peripheral base clock fXP1 Prescaler1 fXX is the clock source for the peripheral base clock fXP1. General purpose peripheral clocks are provided by fixed Prescaler1. This prescaler generates the peripheral clocks (fXP1 to fXP1/1024) to be supplied to on-chip peripheral functions such as timers, serial interfaces and A/ D Converter. (3) Special clocks The Clock Generator provides special clocks for certain peripherals. Clock for UARTDn, TAAn, MLM This clock can be derived from fXP1 or fXP2. Both fXP1 and fXP2 have the same frequency which is either fXX or fXX /2, depending on the setting of bit PRSI in the option bytes. Note that fXP1 stops in all IDLE modes while fXP2 stops only in IDLE2 mode. The timers TAA1 and TAA3 can also be supplied with the SubOSC clock fXT. Clock for TMM0 Clock source for timer TMM can be any of the oscillators. The selection between fXP1 or fRH is made by bit SELCNT0.ISEL07. Clock for CANn The CAN interfaces can be clocked by fXP1 or by fXC, as chosen by a bit in the SELCNTx register. Select fXC when directly supplying the clock generated by a clock oscillator to the CAN controller. Clock for WT After reset, the Watch Timer is clocked by the SubOSC (fXT). This can be changed when the main oscillator has stabilized. WT can then be clocked by the output of Prescaler3 that supplies also the CSIB0 block. Prescaler3 serves as a baud rate generator. It is controlled by the registers PRSM0 and PRSCM0. For details see also "Operation of Prescaler3" on page 216. PCL CLKOUT 162 The Clock Generator has a programmable clock (PCL) output.This output can deliver a fraction of fPLSS (fPLSS divided by 4, 8, 16, or 32), which is derived from fPLLO. It is controlled by register PCLM and must be enabled by setting PCLM.PCLE. This output provides the CPU system clock fVBCLK. During the oscillation stability period, its state becomes Hi-Z. User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 Clock for WDT2 This is the clock for the Watchdog Timer. The clock for WDT2 is available (and hence the Watchdog Timer running) as long as the chosen clock source (240 KHz internal oscillator or MainOSC) is active. Note that the WDT2 operation is defined in option byte 007AH. (4) Stand-by control In the block diagram, you find also boxes labelled "IDLE Control" or "HALT control". These boxes symbolize the switches that are used to disable circuits when the microcontroller enters one of the various power save modes. For an introduction, see "Power save modes overview" on page 164. (5) Summary of clock signals fX: MainOSC clock is input clock to PLL fXT: SubOSC clock fRL: 240 KHz internal oscillator clock fRH: 8 MHz internal oscillator clock fPLLI: PLL input clock. Can be fX or a fraction of fX fPLLO: PLL output clock fPLL: PLL output clock fXX: Main system clock fVBCLK: CPU system clock fCPU: CPU core clock (same clock as fVBCLK, but stops in HALT mode) fXP1: Peripheral clock 1 (output of Prescaler1, stops in IDLE1 mode) fXP2: Peripheral clock 2 (same frequency as fXP1, but continues in IDLE1 mode) fXC: MainOSC clock for CANn interfaces (same frequency as fX, stops in IDLE1 and IDLE2 mode) fSC: Sub clock 4.1.2 Clock Monitor The Clock Monitor supervises the operation of the MainOSC. In case of malfunction, the Clock Monitor can generate a system reset. The monitor requires that the built-in 240 KHz internal oscillator is active. For details see "Operation of the Clock Monitor" on page 217. User's Manual U18743EE1V2UM00 163 Chapter 4 Clock Generator 4.1.3 Power save modes overview The power consumption of the system can be effectively reduced by using the stand-by modes and selecting the appropriate mode for the application. The available stand-by modes are listed below. The following explanations provide a general overview. For details, please refer to "Power save modes description" on page 196 and the register descriptions. HALT mode Mode in which only the operating clock of the CPU (fCPU) is stopped. All other clocks remain active. This mode is entered by executing the HALT instruction. All other power save modes are entered by setting registers. This mode allows quick recovery to the normal operating mode, because it is not necessary to wait for oscillators to be stable or the PLL to be locked. IDLE1 mode Mode in which all the internal operations of the chip except the oscillators, PLL and flash memory are stopped. The PLL holds the previous operating status. This mode allows quick return to the normal operating mode in response to a release signal, because it is not necessary to wait for oscillators to settle or the PLL to lock. IDLE2 mode Mode in which all the internal operations of the chip except the oscillators are stopped. STOP Mode in which all the internal operations of the chip except the Sub oscillator are stopped. Subclock operation Sub-IDLE mode 164 Mode in which the subclock is used as the CPU system clock fVBCLK. Subclock source can be the SubOSC (fXT) or the 240 KHz internal oscillator (fRL). The selection is made by the SUBCLK bit of the option byte 007BH. A mode that can be entered during subclock operation. All the internal operations of the chip except the oscillator, PLL and flash memory are stopped. The PLL holds the previous operating status. User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.1.4 Start conditions After securing the setup time of the 8 MHz internal oscillator, the CPU begins program execution. The oscillation stabilization time for the internal oscillator is ensured by hardware. The table below shows the state during reset and after reset release. Table 4-2 Oscillation during reset period or after reset release Item During the reset period MainOSC (fX) Stopped SubOSC (fXT) Continues oscillation 240 KHz internal oscillator (fRL) Stopped Starts oscillation 8 MHz internal oscillator (fRH) Stopped Starts oscillation PLL (fPLLO) Stopped CPU system clock (fVBCLK) Stopped Starts operation on 8 MHz internal oscillator fRH after internal oscillator stable. Peripheral clocks fXP1 (and fractions thereof), fXP2 Stopped Starts operation on 8 MHz internal oscillator fRH after internal oscillator stable. Programmable clock output PCL (fPCL) Disabled (low level) System clock output CLKOUT (fVBCLK) Stopped User's Manual U18743EE1V2UM00 After releasing reset Output of 8 MHz internal oscillator fRH after internal oscillator stable. Must be enabled by software. 165 Chapter 4 Clock Generator 4.2 Clock Generator Registers The Clock Generator is controlled and operated by means of the following registers (the list is sorted according to memory allocation): Table 4-3 Note Clock Generator register overview Writeprotected by register Register name Shortcut Address Power save control register PSC FFFF F1FEH PRCMD Selector control register 0 SELCNT0 FFFF F308H Selector control register 2 SELCNT2 FFFF F30CH Selector control register 3 SELCNT3 FFFF F30EH Oscillation stabilization time select register OSTS FFFF F6C0H PLL lockup time specification register PLLS FFFF F6C1H Oscillation stabilization timer status register OSTC FFFF F6C2H Internal oscillator oscillator mode register RCM FFFF F80CH Power save mode control register PSMR FFFF F820H PLL lock status register LOCKR FFFF F824H Processor clock control register PCC FFFF F828H PLL control register PLLCTL FFFF F82CH CPU operation clock status register CCLS FFFF F82EH Programmable clock mode register PCLM FFFF F82FH Main system clock mode register MCM FFFF F860H PRCMD Clock Monitor mode register CLM FFFF F870H PRCMD Prescaler3 mode register PRSM0 FFFF F8B0H Prescaler3 compare register PRSCM0 FFFF F8B1H PRCMD Some registers are write-protected to avoid inadvertent changes. Data can be written to these registers only in a special sequence of instructions, so that the register contents is not easily rewritten in case of a program hang-up. Writing to a protected register is only possible immediately after writing to the associated write protection register. For details please refer to "CPU System Functions" on page 135. Note 166 In addition to the registers, control bits must be set in the code flash memory option bytes. For details see "Option Bytes" on page 188. User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 The subsequent register descriptions are grouped as follows: * General clock generator registers: - "CCLS - CPU operation clock status register" on page 168 - "MCM - Main system clock mode register" on page 169 - "OSTC - Oscillation stabilization timer status register" on page 170 - "OSTS - Oscillation stabilization time select register" on page 171 - "PCC - Processor clock control register" on page 173 - "PCLM - Programmable clock mode register" on page 176 * PLL control registers: - "LOCKR - PLL lock status register" on page 178 - "PLLCTL - PLL control register" on page 179 - "PLLS - PLL lockup time specification register" on page 180 * Stand-by control registers - "PSC - Power save control register" on page 181 - "PSMR - Power save mode control register" on page 182 * Prescaler3 control registers: - "PRSM0 - Prescaler3 mode register" on page 183 - "PRSCM0 - Prescaler3 compare register" on page 183 * Clock Monitor registers: - "CLM - Main oscillator Clock Monitor mode register" on page 184 * Selector control registers: - "SELCNT0 - Selector control register 0" on page 185 - "SELCNT2 - Selector control register 2" on page 186 - "SELCNT3 - Selector control register 3" on page 187 User's Manual U18743EE1V2UM00 167 Chapter 4 Clock Generator 4.2.1 General Clock Generator registers The general Clock Generator registers control and reflect the operation of the Clock Generator. (1) CCLS - CPU operation clock status register The CCLS register indicates the CPU operation clock status. Access Address Initial Value Table 4-4 Bit position Bit name 0 CCLSF a) FFFF F82EH. 00H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 CCLSF R R R R R R R R CCLS register contents Function CPU operating clock status: 0: Operates on main system clock fXX or subclock fSCa. 1: Operates on 240 KHz internal oscillator fRL. Subclock fSC is either fXT or fRL, depending on SUBCLK bit of option byte 007BH. Note 168 This register can be read in 1-bit or 8-bit units. If the Watchdog Timer WDT2 overflows before the oscillation stabilization time of the MainOSC has elapsed, this is judged as an abnormal oscillation of the MainOSC fX. Thus the CPU system clock fVBCLK is changed to internal oscillator fRL. User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (2) MCM - Main system clock mode register The 8-bit MCM register specifies the main system clock (fXX) source in clockthrough mode and informs about its status. Access This register can be read/written in 1-bit or 8-bit units. Writing to this register is protected by a special sequence of instructions. Please refer to "CPU System Functions" on page 135 for details. Address Initial Value FFFF F860H. 00H. The register is initialized by any reset. 7 Table 4-5 6 5 4 3 2 1 0 0 0 0 0 0 0 MCS MCM0 R R R R R R R R/W MCM register contents Bit position Bit name Function 1 MCS Status of the main system clock fXX (in clock-through mode, if PLLCTL.SELPLL = 0): 0: Operating on 8 MHz internal oscillator clock fRH. 1: Operating on MainOSC clock fX. 0 MCM0 Clock selection of main system clock fXX: 0: Clock source is the 8 MHz internal oscillator fRH (in clock-through mode). 1: Clock source is - MainOSC fX (in clock-through mode, if PLLCTL.SELPLL = 0) - PLL output fPLL (in PLL mode, if PLLCTL.SELPLL = 1) Caution: 1. When the oscillation of a previous clock switch is not steady, rewriting of this bit is prohibited. 2. The MCM0 can be set to 0 only, if the current mode is clock-through, i.e. PLLCTL.SELPLL = 0. Do not change from PLL mode or subclock operation mode directly to 8 MHz internal oscillator clock-through mode or vice versa. User's Manual U18743EE1V2UM00 169 Chapter 4 Clock Generator (3) OSTC - Oscillation stabilization timer status register The 8-bit OSTC register indicates the status of the main oscillator. Access Address Initial Value Table 4-6 Bit position Bit name 0 MSTS Remarks This register is read-only. FFFF F6C2H. 00H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 MSTS R R R R R R R R OSTC register contents Function Oscillation stabilization status of MainOSC: 0: MainOSC stopped or waiting for oscillation stabilization. 1: MainOSC oscillation stabilization ended. 1. The OSTC register does not monitor the main clock status but indicates the process status, based on the oscillation stabilization time specified by the OSTS register. 2. When the main clock oscillator is stopped by the software (PCC.MCK bit = 1) or entered into STOP mode, the OSTC register is set to 00H. If it is stopped due to abnormal oscillation, the status is maintained. 170 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (4) OSTS - Oscillation stabilization time select register The 8-bit OSTS register specifies the oscillation stabilization time following reset release or release of the STOP mode. The oscillation stabilization time and setup time are required when the STOP mode and IDLE mode are released, respectively. Access Address Initial Value Table 4-7 Bit position This register can be read/written in 1-bit or 8-bit units. FFFF F6C0H. 06H. The register is initialized by any reset. 7 6 5 0 0 0 R R R 4 3 2 OSTS4 OSTS3 OSTS2 R/W R/W 1 0 OSTS1 OSTS0 R/W R/W R/W OSTS register contents Bit name Function Time selection: OSTS4 4 to 0 a) OSTS[4:0] a OSTS3 OSTS2 OSTS1 OSTS0 Selection of oscillation stabilization / setup timeb 0 0 0 0 0 210/fx 0 0 0 0 1 211/fx 0 0 0 1 0 212/fx 0 0 0 1 1 213/fx 0 0 1 0 0 214/fx 0 0 1 0 1 215/fx 0 0 1 1 0 216/fx 0 0 1 1 1 217/fx 0 1 0 0 0 218/fx 0 1 0 0 1 219/fx 0 1 0 1 0 220/fx 0 1 0 1 1 221/fx 1 0 0 0 0 Setting prohibited 1 0 0 0 1 Setting prohibited 1 0 0 1 0 24/fx 1 0 0 1 1 25/fx 1 0 1 0 0 26/fx 1 0 1 0 1 27/fx 1 0 1 1 0 28/fx 1 0 1 1 1 29/fx 1 1 0 0 0 210/fx 1 1 0 0 1 211/fx 1 1 0 1 0 212/fx 1 1 0 1 1 213/fx Bit OSTS4 is only valid during IDLE2 mode release. In case of shifting to the STOP mode at OSTS4 bit = 1, the oscillation stabilization time after STOP mode release is the set period of the OSTS3-0 bits (OSTS4 bit is considered as 0). User's Manual U18743EE1V2UM00 171 Chapter 4 b) Clock Generator For minimum oscillation stabilization / setup times refer to the Electrical Target Specification. Note 1. When IDLE2 mode is released, set the stabilization time to the following requirements: - In case of PLL mode: PLL lockup time requirements - In case of clock-through mode: flash set up time requirement For the exact timing values, refer to the Electrical Target Specification. 2. When STOP mode is released, set the stabilization time to the following requirements: - In case of PLL mode: PLL lockup time requirement - In case of clock-through mode:flash set up time requirement For the exact timing values, refer to the Electrical Target Specification. 3. If the required oscillation stabilization time of the MainOSC exceeds the above times, set the value to the required oscillation stabilization time of the MainOSC. 172 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (5) PCC - Processor clock control register The 8-bit PCC register controls the CPU system clock fVBCLK. Access This register can be read/written in 1-bit and 8-bit units. Writing to this register is protected by a special sequence of instructions. Please refer to "CPU System Functions" on page 135 for details. Address Initial Value Table 4-8 FFFF F828H. 40H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 FRC MCK MFRC CLS CK3 CK2 CK1 CK0 R/W R/W R/W R R/W R/W R/W R/W PCC register contents (1/2) Bit position Bit name Function 7 FRC Use of built-in Sub oscillator feedback resistor: 0: Feedback resistor connected. 1: Feedback resistor not connected. 6 MCK Operation of MainOSC: 0: Oscillation enabled. 1: Oscillation stopped. Note: 1. When the MCK bit is set to 1 while the system is operating with the main system clock as the CPU clock, the operation of the main system clock does not stop. It stops after the CPU clock has been changed to the subclock. 2. When the main system clock is stopped and the device is operating on the subclock, clear the MCK bit to 0 and wait until the oscillation stabilization time has elapsed before switching back to the main system clock. 5 MFRC 4 CLS Use of main oscillator on-chip feedback resistor: 0: Feedback resistor connected. 1: Feedback resistor not connected. Status of CPU system clock fVBCLK: 0: Main system clock fXX operation. 1: Subclock fSC operation. User's Manual U18743EE1V2UM00 173 Chapter 4 Clock Generator Table 4-8 Bit position Bit name 3 to 0 CK[3:0] PCC register contents (2/2) Function Clock selection: CK3 CK2 CK1 CK0 Clock selection 0 0 0 0 fXX 0 0 0 1 fXX/2 0 0 1 0 fXX/4 0 0 1 1 fXX/8 0 1 0 0 fXX/16 0 1 0 1 fXX/32 0 1 1 x Setting prohibited 1 x x x Subclock fSC (fXT or fRL)a Note: 1. Do not change the CPU clock (by using the CK[3:0] bits) while CLKOUT is being output. 2. Use a bit manipulation instruction to manipulate the CK3 bit. When using an 8-bit manipulation instruction, do not change the set values of the CK[2:0] bits. a) Preset in option byte 007BH. Examples: main to subclock 1. Confirmation of operating clock: Confirm that the current clock is in main clock (MCS = 1). Switching from the high speed internal oscillator clock operation to low-speed internal oscillator clock operation is prohibited. In the high-speed internal oscillation clock operation (MCS = 0), set the MCM.MCM0 bit = 1 and then confirm that the MCM.MCM0 bit = 1 again. 2. Confirmation of CPU clock (fCPU) frequency: Confirm that fCPU satisfies either of the following conditions. * When OB7B.SUBLCK = 0, fCPU > subclock oscillation frequency (fXT) (32.768 kHz) x 4 * When OB7B.SUBCLK = 1, fCPU > low-speed internal oscillation clock frequency (fRL) (TYP.240 kHz) x 4 If the above conditions are not satisfied, change the CK2 to CK0 bits setting so as to satisfy the condition. At this time, do not change the CK3 bit. 3. Setting the CK3 bit to "1": Set via bit manipulation instruction. Do not change the CK2-CK0 bits. 4. Subclock operation: The maximum time required for switching to subclock operation or to low-speed internal oscillation clock operation after the CK3 bit is set to 1, is as follows: * When OB7B.SUBCLK = 0: 1 / Subclock oscillation frequency (fXT) * When OB7B.SUBCLK = 1: 1 / low-speed internal oscillation frequency (fRL) Read the CLS bit and confirm that the operation has been switched to the subclock or low-speed internal oscillation operation. 5. Setting the MCK bit to "1": Set the MCK bit = 1 to stop the main oscillator operation. Caution: Stop PLL/SSCG before stopping the main oscillator operation. In addition, stop the operation of internal peripheral functions which operate at the main clock frequency. 174 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 subclock to main 1. Setting the MCK bit to "0": Enables main clock oscillation. 2. Software wait: Insert wait status via program to wait until the oscillation stabilization time of the main clock oscillator (OSTC.MSTS = 1) is elapsed. 3. Setting the CK3 bit to "0": Set via a bit manipulation instruction. Do not change the CK2 to CK0 bits. Main clock operation: The maximum time required for switching to the main clock operation which is specified by the CK2 to CK0 bits after the CK3 bit is set, is as follows. * When OB7B.SUBCLK = 0: 1 / Subclock oscillation frequency (fXT) * When OB7B.SUBCLK = 1: 1 / low-speed internal oscillation frequency (fRL) Read the CLS bit and confirm that the operation has been switched to the main clock operation. Caution Do not change to a different clock selection until the previous one has entered a stable status. User's Manual U18743EE1V2UM00 175 Chapter 4 Clock Generator (6) PCLM - Programmable clock mode register The 8-bit PCLM register specifies the setting the programmable clock output PCL. Access Address Initial Value Table 4-9 Bit position Bit name 4 PCLE 1 to 0 PCK[1:0] Note 176 This register can be read/written in 1-bit or 8-bit units. FFFF F82FH. 00H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 PCLE 0 0 PCK1 PCK0 R R R R/W R R R/W R/W PCLM register contents Function PCL enable: 0: PCL disabled (PCL pin is fixed to low level). 1: PCL enabled. PCL clock frequency selection: PCK1 PCK0 PCL output clock 0 0 fPCL= fPLLO/4 0 1 fPCL= fPLLO/8 1 0 fPCL= fPLLO/16 1 1 fPCL= fPLLO/32 A PCL clock is only output when the PLL is in locked status. User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (7) RCM - Internal oscillator mode register The 8-bit RCM register specifies the operation and informs about the status of the low-speed and high-speed internal oscillators. Access Address Initial Value Table 4-10 Bit position Bit name 7 RSTS 1 HRSTOP This register can be read/written in 1-bit or 8-bit units. FFFF F80CH. 80H. The register is initialized by any reset. 7 6 5 4 3 2 RSTS 0 0 0 0 0 R R R R R R 1 0 HRSTOP RSTOP R/W R/W RCM register contents Function Oscillation stability status of 8 MHz internal oscillator: 0: 8 MHz internal oscillator stopped or waiting for oscillation stability. 1: 8 MHz internal oscillator operating. Operation/stop of 8 MHz internal oscillator: 0: 8 MHz internal oscillator operating. 1: 8 MHz internal oscillator stopped. Caution: When the CPU clock source is the 8 MHz internal oscillator, do not set this bit to 1. 0 RSTOP Operation/stop of 240 KHz internal oscillator: 0: 240 KHz internal oscillator operating. 1: 240 KHz internal oscillator stopped. Note: Setting this bit is ignored if bit RMOPIN of option byte 007AH is set. Caution: When the CPU clock source is the 240 KHz internal oscillator, do not set this bit to 1. User's Manual U18743EE1V2UM00 177 Chapter 4 Clock Generator 4.2.2 PLL control registers The Clock Generator's PLL registers control and reflect the operation of the PLL. (1) LOCKR - PLL lock status register Phase lock occurs at a given frequency following power application or immediately after the STOP mode is released, and the time required for stabilization is the lockup time (frequency stabilization time). This time until stabilization is called the lockup status, and the stabilized state is called the locked status. The lock register LOCKR includes a LOCK bit that reflects the PLL frequency stabilization status. Access Address Initial Value Table 4-11 Bit position Bit name 0 LOCK This register is read-only, in 8-bit or 1-bit units. FFFF F824H. 01H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 LOCK R R R R R R R R LOCKR register contents Function PLL lock status check: 0: Locked status. 1: Unlocked status The LOCK register does not reflect the lock status of the PLL in real time. The set/reset conditions are as follows: Set conditions * Upon system reset. This register is set to 01H by reset and cleared to 00H after the reset has been released and the oscillation stabilization time has elapsed. * In STOP and IDLE2 mode. * Upon setting the PLL to stop (clearing bit PLLCTL.PLLON). * Upon stopping the main system clock and using the CPU with subclock (setting bits PCC.CK3 and PCC.MCK to 1). Clear conditions * After reset release and overflow of oscillation stabilization time counter (OSTS register default time). * When bit PLLCTL.PLLON is changed from 0 to 1 after PLL lockup timer overflow (time set by PLLS register). * After STOP mode release and oscillation stabilization time counter overflow (time set by OSTS register), when the STOP mode was set while the PLL was in PLL mode. * After IDLE2 mode release and oscillation stabilization timer overflow (time set by OSTS register), when the IDLE2 mode was set while the PLL was in PLL mode. Note 178 The PLL can enter the locked status only, if the MainOSC is enabled, i.e. PCC.MCLK = 0. User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (2) PLLCTL - PLL control register The 8-bit PLLCTL register controls the PLL function. Access Address Initial Value This register can be read or written in 8-bit or 1-bit units. FFFF F82CH. 00H. The register is initialized by any reset. 7 Table 4-12 6 5 4 3 2 0 0 0 0 0 0 R R R R R R 1 0 SELPLL PLLON R/W R/W PLLCTL register contents Bit position Bit name 1 SELPLL Main system clock fXX mode selection: 0: Clock-through mode (fXX is MainOSC fX or 8 MHz internal oscillator fRH clock, depending on MCM.MCM0). 1: PLL mode (fXX is PLL output fPLL, if MCM.MCM0 = 1 as well). 0 PLLON Control of PLL operation/stop: 0: PLL stopped. 1: PLL started. (After PLL operation starts, a lockup time is required for frequency stabilization). Note Function 1. The SELPLL bit can be set to 1 only -if the PLL clock frequency has stabilized -and current mode is clock-through with MainOSC fX as main system clock fXX, i.e. MCM.MCM0 = 1 If the PLL is unlocked or MCM.MCM0 = 0 (clock-through mode with internal oscillator fRH), SELPLL can not be changed to 1. Thus you can not change from 8 MHz internal oscillator clock-through mode directly to PLL mode. 2. When the PLLON bit is cleared to 0, the SELPLL bit is automatically cleared to 0 (clock-through mode). 3. When the PLLON bit = 1 and the main clock is stopped, PLL stops the operation. User's Manual U18743EE1V2UM00 179 Chapter 4 Clock Generator (3) PLLS - PLL lockup time specification register The 8-bit PLLS register specifies the settling time of the PLL. Access Address Initial Value Table 4-13 Bit position Bit name 2 to 0 PLLS[2:0] Note Caution 180 This register can be read/written in 8-bit units. FFFF F6C1H. 03H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 0 0 PLLS2 PLLS1 PLLS0 R R R R R R/W R/W R/W PLLS register contents Function PLL lockup time selection: PLLS2 PLLS1 PLLS0 Lockup time 0 1 0 212/fX 0 1 1 213/fX (default value) 1 0 0 214/fX For the exact lockup time, refer to the Electrical Target Specification. Do not change the setting of the PPLS register during the PLL lock-up time. User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.2.3 Stand-by control registers These registers control and reflect the various stand-by modes that can be entered for saving power. (1) PSC - Power save control register The 8-bit PSC register controls the stand-by function. The STP bit of this register specifies the stand-by mode. Access This register can be read/written in 8-bit or 1-bit units. Writing to this register is protected by a special sequence of instructions. Please refer to "Write Protected Registers" on page 155 for details. Address Initial Value Table 4-14 FFFF F1FEH. 00H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 NMI1M NMI0M INTM 0 0 STP 0 R R/W R/W R/W R R R/W R PSC register contents Bit position Bit name Function 6 NMI1M Stand-by mode release control by occurrence of INTWDT2 signal: 0: Enable releasing stand-by mode by INTWDT2 signal. 1: Disable releasing stand-by mode by INTWDT2 signal. 5 NMI0M Stand-by mode release control by NMI pin input: 0: Enable releasing stand-by mode by NMI pin input. 1: Disable releasing stand-by mode by NMI pin input. 4 INTM Stand-by mode release control by maskable interrupt request signal: 0: Enable releasing stand-by mode by maskable interrupt request signal. 1: Disable releasing stand-by mode by maskable interrupt request signal. 1 STP Setting of stand-by mode: 0: Normal mode. 1: Stand-by mode. Note: 1. Stand-by modes that can be set by the STP bit: IDLE1 mode, IDLE2 mode, STOP mode, and sub-IDLE mode. 2. Before setting this bit, set the bits PSMR.PSM[1:0]. When writing to this register, follow the instructions given in "CPU System Functions" on page 135. Entering a power save mode requires some attention, refer to "Power save mode activation" on page 213. Caution Entering a power save mode requires special attention, refer to "Power save mode activation" on page 213. User's Manual U18743EE1V2UM00 181 Chapter 4 Clock Generator (2) PSMR - Power save mode control register The 8-bit PSMR register is used to specify one of the power save modes. The setting becomes effective when the mode is entered by setting PSC.STP to 1. Access Address Initial Value Table 4-15 Bit position Bit name 1 to 0 PSM[1:0] This register can be read/written in 1-bit or 8-bit units. FFFF F820H. 00H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 0 0 0 PSM1 PSM0 R R R R R R R/W R/W PSMR register contents Function Specification of operation in software stand-by mode: PSM1 PSM0 Power save mode 0 0 IDLE1 mode 0 1 STOP mode 1 0 IDLE2 mode or sub-IDLE modea 1 1 STOP mode Note: The PSM0 and PSM1 bits take effect after PSC.STP = 1. a) Sub-IDLE mode is entered if the processor is in subclock mode (clocked by fXT or fRL). For information on these modes, refer to "Power save modes description" on page 196. 182 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.2.4 Prescaler3 control registers These registers control the Prescaler3 that generates fBRG which can be applied to the Watch Timer and the Clocked Serial Interface CSIB0. Prescaler3 includes a clock divider, a counter, and a comparator. For details see "Operation of Prescaler3" on page 216. (1) PRSM0 - Prescaler3 mode register The PRSM0 register controls the Prescaler3 operation. Access Address Initial Value Table 4-16 This register can be read/written in 8-bit units. FFFF F8B0H. 00H. This register is cleared by any reset. 6 5 4 3 2 1 0 0 0 0 BGCE0 0 0 BGCS01 BGCS00 R R R R/W R R R/W R/W PRSM0 register contents Bit position Bit name 4 BGCE0 1 to 0 BGCS0[1:0] Note 7 Function Prescaler3 output: 0: Disabled. 1: Enabled. Selection of counter clock: BGCS01 BGCS00 Prescaler clock selection 0 0 fX 0 1 fX /2 1 0 fX /4 1 1 fX /8 1. Do not change the values of BGCS0[1:0] during Watch Timer operation. 2. Set the BGCS0[1:0] bits before setting the BGCE0 bit to 1. 3. Set the PRSM0 and PRSCM0 registers according to the main clock frequency that is used to obtain an fBRG frequency of 32,768 KHz. (2) PRSCM0 - Prescaler3 compare register The PRSCM0 register specifies the compare value and hence the output frequency of fBRG. Access Address Initial Value This register can be read/written in 8-bit units. FFFF F8B1H. 00H. This register is cleared by any reset. 7 6 5 4 3 2 PRSCM7 PRSCM6 PRSCM5 PRSCM4 PRSCM3 PRSCM2 R/W R/W R/W R/W User's Manual U18743EE1V2UM00 R/W R/W 1 0 PRSCM1 PRSCM0 R/W R/W 183 Chapter 4 Clock Generator Note 1. Do not rewrite the PRSCM0 register during Watch Timer operation. 2. Set the PRSM0 and PRSCM0 registers according to the main clock frequency that is used to obtain an fBRG frequency of 32,768 KHz. For details and a calculation example, please refer to "Operation of Prescaler3" on page 216. 4.2.5 Clock Monitor control registers These registers control and reflect the operation of the Clock Monitor. (1) CLM - Main oscillator Clock Monitor mode register The 8-bit CLM register is used to enable the monitor for the main oscillator clock. Access This register can be read/written in 8-bit or 1-bit units. Writing to this register is protected by a special sequence of instructions. Please refer to "CPU System Functions" on page 135 for details. Address Initial Value FFFF F870H. 00H. This register is cleared by any reset. 7 Table 4-17 5 4 3 2 1 0 0 0 0 0 0 0 0 CLME R R R R R R R R/W CLM register contents Bit position Bit name 0 CLME Note 6 Function Clock Monitor enable: 0: Clock Monitor for main oscillator disabled. 1: Clock Monitor for main oscillator enabled. This bit can only be cleared by reset. 1. CLM.CLME can be set at any time. However, the Clock Monitor is only activated after the main oscillator has stabilized, indicated by OSTC.MSTS = 1. 2. When reset is generated by the clock monitor, CLM.CLME is cleared to 0 and RESF.CLMRF is set to 1. 184 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.2.6 Selector control registers These registers are used to select the clocks and functions of timers TAAn, TMM0 and serial interfaces UARTDn, CANn. Note (1) In this section, only the bits that refer to clock generation and distribution are described. For further information please refer to the descriptions of the onchip peripherals. SELCNT0 - Selector control register 0 The 8-bit SELCNT0 register is used to specify the clock for timer TMM0. Access Address Initial Value This register can be read/written in 8-bit or 1-bit units. FFFF F308H. 00H. The register is initialized by any reset. * V850ES/FE3-L * V850ES/FF3-L 7 6 5 4 3 ISEL07 0 0 R/W R R R/W R/W 5 4 3 2 1 0 0 ISEL00 R/W R R/W 2 1 0 0 ISEL00 R R/W ISEL04 ISEL03 ISEL02 * V850ES/FG3-L Note Table 4-18 Bit position Bit name 7 ISEL07 6 to 0 ISEL0[6:0] 7 6 ISEL07 0 R/W R ISEL05 ISEL04 ISEL03 ISEL02 R/W R/W R/W R/W "R" bits marked with "0" must not be changed from their default value "0". SELCNT0 register contents Function Selection of count clock for TMM0: 0: Clock = fXP1/512. 1: Clock = fRH/8. Refers to TAAn. User's Manual U18743EE1V2UM00 185 Chapter 4 Clock Generator (2) SELCNT2 - Selector control register 2 The 8-bit SELCNT2 register is used to specify the clock for UARTD0, UARTD1, CAN0 and TAAn. Access Address Initial Value This register can be read/written in 8-bit or 1-bit units. FFFF F30CH. 00H. The register is initialized by any reset. 7 ISEL27 R/W Table 4-19 6 5 4 3 2 ISEL26 ISEL25 ISEL24 ISEL23 ISEL22 R/W R/W R/W R/W R/W 1 0 ISEL21 ISEL20 R/W R/W SELCNT2 register contents Bit position Bit name 7 ISEL27 Selection of UARTD1 clock: 0: Clock = fXP1. The clock that stops in the IDLE1 mode. 1: Clock = fXP2. The clock that does not stop in the IDLE1 mode. 6 ISEL26 Selection of UARTD0 clock: 0: Clock = fXP1. 1: Clock = fXP2. 5 ISEL25 Selection of CAN0 clock: 0: Clock = fXP1. 1: Clock = fXC. 4 ISEL24 Selection of TAA4 counter clock: 0: Clock = fXP1. 1: Clock = fXP2. 3 ISEL23 Selection of TAA3 counter clock: 0: Clock = fXP1. 1: Clock = fXP2. 2 ISEL22 Selection of TAA2 counter clock: 0: Clock = fXP1. 1: Clock = fXP2. 1 ISEL21 Selection of TAA1 counter clock: 0: Clock = fXP1. 1: Clock = fXP2. 0 ISEL20 Selection of TAA0 counter clock: 0: Clock = fXP1. 1: Clock = fXP2. 186 Function User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (3) SELCNT3 - Selector control register 3 The 8-bit SELCNT3 register is used to specify the clocks for UARTD2. Access Address Initial Value This register can be read/written in 8-bit or 1-bit units. FFFF F30EH. 00H. The register is initialized by any reset. * V850ES/FG3-L Note Table 4-20 Bit position Bit name 2 ISEL32 7 6 5 4 3 2 1 0 0 0 0 0 0 ISEL32 0 0 R R R R R R/W R R "R" bits marked with "0" must not be changed from their default value "0". SELCNT3 register contents Function Selection of UARTD2 clock: 0: Clock = fXP1. 1: Clock = fXP2. User's Manual U18743EE1V2UM00 187 Chapter 4 Clock Generator 4.3 Option Bytes The code flash memory versions in this product series have an option data area where a block subject to mask options is specified. When writing a program to a code flash memory version, be sure to set the option data area corresponding to the following option bytes. The option bytes are used for: * Enable or disable stopping the 240 KHz internal oscillator by software * Specifying the WDT2 operation mode * Selection of SubOSC external connection (crystal or RC resonator) * Selection of clock source in subclock operation mode (SubOSC or 240 KHz internal oscillator) * Selection of PLL input clock * Selection of PLL output clock * Selection of peripheral clock The option bytes are stored as 16-bit data at addresses 0000 007AH and 0000 007BH of the internal code flash memory. Note 188 In the following only the Clock generator related option bytes settings are described. For a complete overview refer to "Flash Mask Options" on page 285. User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.3.1 Option byte 0000 007AH Address 0000 007AH. 7 6 STOPXTAL STOPRCZ Note Table 4-21 Bit position 7 to 6 5 4 3 2 1 0 0 0 0 0 WDTMD1 RMOPIN Bits marked with "0" must not be changed from their value "0". Setting of option byte 0000 007AH Bit name Function STOPXTAL, Selection of SubOSC mode: STOPRCZ STOPXTAL STOPRCZ Sub oscillator setting 0 0 Crystal oscillator mode (32,768 KHz) 1 1 RC oscillator mode (20 KHz) other than above 1 WDTMD1 Setting prohibited Specifies WDT2 operation mode: 0: Count operation: Can be stopped by WDM2.WDCS24. Input clock: Selectable by WDTM2 register. 240 KHz internal oscillator or MainOSC. Operation mode: Selectable by WDTM2 register. NMI interrupt (INTWDT2) or reset mode (WDT2RES) selectable. 1: Count operation: Cannot be stopped. Input clock: Fixed to 240 KHz internal oscillator. Operation mode: Fixed to reset mode (WDT2RES). 0 RMOPIN Option that the 240 KHz internal oscillator can be stopped by software: 0: Can be stopped by software. 1: Cannot be stopped. User's Manual U18743EE1V2UM00 189 Chapter 4 Clock Generator 4.3.2 Option byte 0000 007BH Address Note Table 4-22 0000 007BH. 7 6 5 4 3 2 1 0 SUBCLK 0 0 LATENCY PLLO PRSI PLLI1 PLLI0 Bits marked with "0" must not be changed from their value "0". Setting of option byte 0000 007BH Bit position Bit name 7 SUBCLK 4 LATENCY refer to "Flash Mask Options" on page 285 3 190 PLLO 2 PRSI 1 to 0 PLLI[1:0] Function Clock source in subclock operating mode: 0: SubOSC selection. 1: 240 KHz internal oscillator selection. PLL output clock fPLLand fXMPLL selection: PLLO fXMPLL fPLL 0 (setting prohibited) fPLLO fPLLO 1 fPLLO/2 fPLLO/2 Divider Setting for peripheral clocks fXP1 and fXP2: 0: fXP1, fXP2 = fXX 1: fXP1, fXP2 = fXX /2 PLL input clock frequency selection: PLLI1 PLLI0 PLL input clock 0 0 fPLLI = fX 0 1 fPLLI = fX/2 1 x fPLLI = fX/4 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.4 Clock Generator Operation This chapter describes the specific features of the Clock Generator. For details see: * "Overview of clock operation control settings" on page 191 * "Operation state transitions" on page 192 * "Power save modes description" on page 196 * "Available clocks in power save modes" on page 211 * "Controlling the PLL" on page 215 * "Watch Dog Timer Clock" on page 215 * "CLKOUT function" on page 215 * "Operation of Prescaler3" on page 216 * "Operation of the Clock Monitor" on page 217 4.4.1 Overview of clock operation control settings The following table gives an overview of the settings that specify the CPU system clock fVBCLK. It identifies the register bits that must be set or cleared to generate specific fVBCLK. Table 4-23 CCLS.CCLSF 0 PCC.CLS 0 (Main system clock operation mode) 1 (Subclock operation mode) 1 CPU system clock settings PLLCTL.SELPLL 0 (Clock-through mode) MCM.MCM0 0 (8 MHz internal oscillator mode) Operation Clock 8 MHz internal oscillator clock operation xa MainOSC clock operation PLL operation 1 (PLL mode) 1 (MainOSC mode) x Other than above a) Option byte 007B: SUBCLK bit 0 SubOSC clock operation (SubOSC mode) 1 240 KHz internal oscillator (240 KHz internal clock operation (Sub) oscillator mode 2) 240 KHz internal oscillator clock operation (Security) Setting prohibited x = don't care User's Manual U18743EE1V2UM00 191 Chapter 4 Clock Generator 4.4.2 Operation state transitions The following figure illustrates the various state transitions. RESET Each STBY (HALT/IDLE1/IDLE2/ Software STOP) 8 MHz internal oscillator operation Oscillation stabilization wait PLL operation (PLL = ON) Each STBY (HALT/IDLE1/IDLE2/ Software STOP) X1 main clock-through (PLL = ON) Note 1 X1 main through (PLL = OFF) Each STBY (HALT/IDLE1/IDLE2/ Software STOP) SUB operation (X1 = ON) (PLL = ON) STBY (Sub IDLE only) (X1 = ON) (PLL = ON) Note 2 Each STBY (HALT/IDLE1/IDLE2/ Software STOP) SUB operation (X1 = ON) (PLL = OFF) SUB operation (X1 = OFF) (PLL = OFF) STBY (Sub IDLE only) (X1 = OFF) (PLL = OFF) Figure 4-2 Note STBY (Sub IDLE only) (X1 = ON) (PLL = OFF) Operation state transition diagram 1. When the PLL operation mode is entered, secure the lockup time by using software and check the PLL lock status by using the LOCKR.LOCK bit. 2. When changing the operation mode to the main clock oscillator mode, secure the oscillation stabilization time by using software and check the oscillation stabilization status by using the OSTC.OSTS bit. Enable the PLL operation before the main clock oscillator is enabled or after the oscillation is stabilized. 192 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (1) Status transition from PLL operation PLL operation (PLL = ON) Note 2 Note 1 HALT mode X1 = ON, PLL = ON Software STOP mode X1 = OFF, PLL = OFF IDLE1 mode IDLE2 mode X1 = ON, PLL = ON Figure 4-3 Note X1 = ON, PLL = OFF Stand-by transition from PLL operation (PLL = ON) 1. After the time set by the OSTS register has elapsed, the CPU returns to the PLL mode. 2. After the time set by the OSTS register has elapsed, the CPU returns to the PLL mode. If the Watchdog Timer overflows (reset) while the oscillation stabilization time is being counted, the CPU starts clock operation with the internal oscillator. (2) Status transition from main clock-through operation (with PLL on) X1 main clock-through mode (PLL = ON) Note 2 Note 1 HALT mode X1 = ON, PLL = ON X1 = OFF, PLL = OFF IDLE1 mode X1 = ON, PLL = ON Figure 4-4 Note Software STOP mode IDLE2 mode X1 = ON, PLL = OFF Stand-by transition from x1 main clock-through operation (PLL = ON) 1. After the time set by the OSTS register has elapsed, the CPU returns to the through mode. 2. After the time set by the OSTS register has elapsed, the CPU returns to the through mode. If the Watchdog Timer overflows (reset) while the oscillation stabilization time is counted, the CPU starts its clock operation with the internal oscillator. User's Manual U18743EE1V2UM00 193 Chapter 4 Clock Generator (3) Status transition from main clock-through operation (with PLL off) X1 main clock-through mode (PLL = OFF) Note 2 Note 1 HALT mode X1 = ON, PLL = OFF Software STOP mode X1 = OFF, PLL = OFF IDLE1 mode X1 = ON, PLL = OFF IDLE2 mode X1 = ON, PLL = OFF Figure 4-5 Stand-by transition from x1 main clock-through operation (PLL = OFF) Note 1. After the time set by the OSTS register has elapsed, the CPU returns to the through mode. 2. After the time set by the OSTS register has elapsed, the CPU returns to the through mode. If the Watchdog Timer overflows (reset) while the oscillation stabilization time is counted, the CPU starts its clock operation with the internal oscillator. 194 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (4) Status transition to / from subclock operation Normal operation mode (main clock operation) Subclock operation setting Main clock operation setting Subclock operation mode IDLE mode setting Interrupt Sub-IDLE mode Figure 4-6 Status transition diagram (during subclock operation) User's Manual U18743EE1V2UM00 195 Chapter 4 Clock Generator 4.4.3 Power save modes description This section explains the various power save modes in detail. Table 4-24 Stand-by modes Mode Functional Outline HALT mode Mode in which only the operating clock of the CPU is stopped IDLE1 mode Mode in which all the internal operations of the chip except the oscillator, PLL and flash memory are stopped IDLE2 mode Mode in which all the internal operations of the chip except the oscillator are stopped STOP mode Mode in which all the internal operations of the chip except the subclock oscillator are stopped Subclock operation mode Mode in which the subclock is used as the CPU system clock Sub-IDLE mode During power save mode Mode in which all the internal operations of the chip except the oscillator, PLL and flash memory are stopped, in the subclock operation mode During all power save modes, the pins behave as follows: * All output pins retain their function. That means all outputs are active, provided the required clock source is available. * All input pins remain as input pins. * All input pins with stand-by wake-up capability remain active, the function of all others is disabled. During all power save modes, the main oscillator Clock Monitor remains active, provided that the oscillator is operating. If the oscillator is switched off during stand-by, the Clock Monitor enters stand-by as well. Wake-up signals The following signals can awake the controller from power save modes: * Reset signals - external RESET - Power-On-Clear reset RESPOC - Watchdog Timer reset RESWDT2 The Watchdog Timer must be configured to generate the reset in case of overflow and its input clock must be active during stand-by. - Clock Monitor reset RESCLM The main oscillator must be active during stand-by. * Non maskable interrupts - NMI0 The appropriate port must be configured correctly. - NMIWDT2 The Watchdog Timer must be configured to generate the interrupt in case of overflow and its input clock must be active during stand-by. 196 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 * Maskable interrupts - any unmasked maskable interrupt Note that not all these signals are available in all power save modes. Note (1) In the following tables the clock status "operates" does not necessarily mean that the functions that use this clock source are operating as well. HALT mode In this mode, the clock oscillators continue operating, but clock supply to the CPU is stopped. Clock supply to the other on-chip peripheral functions continues. As a result, program execution is stopped, and the contents of the internal RAM before the HALT mode was set are retained. The on-chip peripheral functions that are not dependent upon the instruction processing of the CPU continue operating. The HALT mode can reduce the average current consumption of the system if it is used with the normal operation mode for intermittent operation. Entering HALT mode Note HALT mode status Table 4-25 When the HALT instruction is executed in the normal operation mode, the HALT mode is set. Insert five or more NOP instructions after the HALT instruction. If the HALT instruction is executed while an interrupt request signal is held pending, the HALT mode is set but is released immediately by the pending interrupt request. The following table shows the operation status in the HALT mode. Controller status in HALT mode (1/2) Working condition Without Subclock MainOSC (fX) Oscillation enabled SubOSC (fXT) - With Subclock Oscillation enabled 240 KHz internal oscillator (fRL) Oscillation enabled 8 MHz internal oscillator (fRH) Oscillation enabled PLL (fPLLO) Operable CPU Stops operation Port function Holds status before HALT mode is set Timer/counter TAA0 -TAA4 TAA0, 2, and 4: Operable Operable TAA1 and 3: Operable, when other than fXT is selected as the count clock Operable, when other than fXT is selected as the count clock TMM0 Watch Timer (WT) Operable Watchdog Timer (WDT2) Operable AD converter Operable Serial Interface UARTD0-2 Operable CSIB0-1 Operable IIC00 Operable User's Manual U18743EE1V2UM00 Operable 197 Chapter 4 Clock Generator Table 4-25 Controller status in HALT mode (2/2) Working condition Without Subclock With Subclock CAN Controller(CAN0) Operable Interrupt Controller Operable Key interrupting function Operable Clock Monitor Operable Power-On-Clear circuit Operable Low-Voltage Detector Operable Voltage Regulator Operation continues Internal data The CPU registers, states, data and all other internal data such as the contents of the internal RAM are retained as they were before HALT mode was set Leaving HALT mode The HALT mode is released by a non-maskable interrupt request signal (NMI pin input or INTWDT2 signal), unmasked external interrupt request signal, unmasked internal interrupt request of a peripheral function that can operate in the HALT mode, or reset signal (reset by RESET pin input, WDT2RES signal, Low-Voltage Detector (LVI), or Clock Monitor (CLM)). When the HALT mode has been released, the normal operation mode is restored. (a) Release by non-maskable interrupt request or unmasked maskable interrupt request The HALT mode is released by a non-maskable interrupt request signal or an unmasked maskable interrupt request signal, regardless of the priority of the interrupt request signal. If the HALT mode is set in an interrupt routine, however, the operation is performed as follows: * If an interrupt request signal having a priority lower than that of the interrupt request currently being serviced is generated, the HALT mode is released, but the interrupt request with the lower priority is not acknowledged. The interrupt request signal itself is held. * If an interrupt request signal (including a non-maskable interrupt request signal) having a priority higher than that of the interrupt request currently being serviced is generated, the HALT mode is released, and this interrupt request signal is acknowledged. Table 4-26 Operation after HALT mode is released by interrupt request signal Releasing Source Interrupt Enabled (EI) Status Non-maskable interrupt request signal Execution branches to the handler address. Maskable interrupt request signal Execution branches to the handler address, or the next instruction is executed. Interrupt Disabled (DI) Status The next instruction is executed. (b) Releasing by RESET input The operation is the same as the normal reset operation. 198 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (2) IDLE1 mode In the IDLE1 mode, the main oscillator, PLL and flash memory continue operating, but clock supply to the CPU and the other on-chip peripheral functions is stopped. As a result, program execution is stopped, and the contents of the internal RAM before the IDLE1 mode was set are retained. The CPU and other on-chip peripheral functions stop operating. However, the on-chip peripheral functions that can operate on the subclock or external clock continue operating. The IDLE1 mode can reduce current consumption more than the HALT mode because the operations of the on-chip peripheral functions are stopped. Because the main oscillator is not stopped, however, the normal mode can be restored without securing the oscillation stabilization time, in the same manner as in the HALT mode. Entering IDLE1 mode IDLE1 mode status Table 4-27 The IDLE1 mode is set when the PSM1 and PSM0 bits of the PSMR register are cleared to "00" and the STP bit of the PSC register is set to 1 in the normal operation mode. Insert five or more NOP instructions after the store instruction that manipulates the PSC register to set the IDLE1 mode. The following table shows the operation status in the IDLE1 mode. Controller status in IDLE1 mode (1/2) Working condition Without Subclock MainOSC (fX) Oscillation enabled SubOSC (fXT) - With Subclock Oscillation enabled 240 KHz internal oscillator (fRL) Oscillation enabled 8 MHz internal oscillator (fRH) Oscillation enabled PLL (fPLLO) Operable CPU Stops operation Port function Holds status before IDLE1 mode is set Timer/counter TAA0 -TAA4 Operable, if fXP2 is selected as the count TAA0, 2, and 4: Operable, if fXP2 is clock selected as the count clock. TAA1 and 3: Operable, if fXP2 or fXT is selected as the count clocka TMM0 Operable, if fRH/8 , fRL/8 ir INTWT is selected as the count clock Operable if fRH/8, fRL/8, INTWT or fXT is selected as count clock. Watch Timer (WT) Operable, if clocked by Prescaler3 Operable Watchdog Timer (WDT2) Operable AD converterb Serial Interface Stops operation UARTD0-2 UARTD0: Operable if either fXP2 or ASCKD0 is selected input clock UARTD1-2: Operable if fXP2 is selected as operation clock. CSIB0-1 Operable, if SCKBn is selected as input clock. IIC00 Stops operation CAN Controller (CAN0) Stops operation Interrupt Controller Stops operation (But it is possible to leave IDLE1 Mode) Key interrupting function Operable Clock Monitor Operable User's Manual U18743EE1V2UM00 199 Chapter 4 Clock Generator Table 4-27 Controller status in IDLE1 mode (2/2) Working condition Without Subclock With Subclock Power-On-Clear circuit Operable Low-Voltage Detector Operable Voltage Regulator Operation continues Internal data The CPU registers, states, data and all other internal data such as the contents of the internal RAM are retained as they were before IDLE1 mode was set a) b) Only when setting the ISELxx bit =1 (fXP2), the count operation by fXT is also possible. To achieve low power consumption, stop the A/D Converter before shifting to the IDLE1 mode. Leaving IDLE1 mode Note The IDLE1 mode is released by a non-maskable interrupt request signal (NMI pin input or INTWDT2 signal), unmasked external interrupt request signal, unmasked internal interrupt request signal of a peripheral function that can operate in the IDLE1 mode, or reset signal. Interrupt request signals that are disabled by the NMI1M, NMI0M, and INTM bits of the PSC register are invalid and do not release the IDLE1 mode. When digital noise elimination is enabled for INTP3, the power save mode cannot be released using INTP3 pin. For details, refer to "Pin Functions" on page 31. When the IDLE1 mode has been released, the normal operation mode is restored. 200 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (a) Release by non-maskable interrupt request or unmasked maskable interrupt request The IDLE1 mode is released by a non-maskable interrupt request signal or an unmasked maskable interrupt request signal, regardless of the priority of the interrupt request signal. If the IDLE1 mode is set in an interrupt routine, however, the operation is performed as follows: * If an interrupt request signal having a priority lower than that of the interrupt request currently being serviced is generated, the IDLE1 mode is released, but the interrupt request with the lower priority is not acknowledged. The interrupt request signal itself is held. * If an interrupt request signal (including a non-maskable interrupt request signal) has a priority higher than that of the interrupt request currently being serviced is generated, the IDLE1 mode is released, and this interrupt request signal is acknowledged. Table 4-28 Operation after IDLE1 mode is released by interrupt request signal Releasing Source Interrupt Enabled (EI) Status Non-maskable interrupt request signal Execution branches to the handler address. Maskable interrupt request signal Execution branches to the handler address, or the next instruction is executed. Interrupt Disabled (DI) Status The next instruction is executed. (b) Releasing by RESET input The operation is the same as the normal reset operation. (3) IDLE2 mode In the IDLE2 mode, the main clock oscillator continues operating, but clock supply to the CPU, PLL, flash memory, and the other on-chip peripheral functions is stopped. As a result, program execution is stopped, and the contents of the internal RAM before the IDLE2 mode was set are retained. Not only the CPU but also the other on-chop peripheral functions stop operating. However, the on-chip peripheral functions that can operate on the subclock or external clock continue operating. The IDLE2 mode can reduce current consumption more than the IDLE1 mode because the operations of the on-chip peripheral functions and flash memory are stopped. Because the PLL and flash memory are stopped, however, setup times for the PLL and flash memory must be maintained after the IDLE2 mode is released. Entering IDLE2 mode Note The IDLE2 mode is set when the PSM1 and PSM0 bits of the PSMR register are set to "10" and the STP bit of the PSC register is set to 1 in the normal operation mode. Insert five or more NOP instructions after the store instruction that manipulates the PSC register to set the IDLE2 mode. User's Manual U18743EE1V2UM00 201 Chapter 4 Clock Generator IDLE2 mode status Table 4-29 The following table shows the operation status in the IDLE2 mode. Controller status in IDLE2 mode Working condition Without Subclock MainOSC (fX) Oscillation enabled SubOSC (fXT) - With Subclock Oscillation enabled 240 KHz internal oscillator (fRL) Oscillation enabled 8 MHz internal oscillator (fRH) Oscillation enabled PLL (fPLLO) Stops operation CPU Stops operation Port function Holds status before IDLE2 mode is set Timer/counter TAA0 -TAA4 Stops operation TMM0 Operable if fRH/8, fRL/8 or INTWT is selected as count clock. Operable if fRH/8, fRL/8, INTWT or fXT is selected as count clock. Watch Timer (WT) Operable, if clocked by Prescaler3 Operable Watchdog Timer (WDT2) Operable AD convertora Serial Interface Stops operation UARTD0-2 UARTD0: Operable if ASCKD0 is selected as input clock UARTD1-2: Operation stops CSIB0-1 Operable, if SCKBn is selected as input clock. IIC00 Stops operation CAN Controller (CAN0) Stops operation Interrupt Controller Stops operation (But it is possible to leave IDLE2 Mode) Key interrupting function Operable Clock Monitor Operable Power-On-Clear circuit Operable Low-Voltage Detector Operable Voltage Regulator Operation continuous Internal data The CPU registers, states, data and all other internal data such as the contents of the internal RAM are retained as they were before IDLE2 mode was set a) To achieve low power consumption, stop the A/D Converter before shifting to the IDLE2 mode. Leaving IDLE2 mode The IDLE2 mode is released by a non-maskable interrupt request signal (NMI pin input or INTWDT2 signal), unmasked external interrupt request signal, unmasked internal interrupt request of a peripheral function that can operate in the IDLE2 mode, or reset signal. When the IDLE2 mode has been released, the normal operation mode is restored. Note 1. Interrupt request signals that are disabled by the NMI1M, NMI0M, and INTM bits of the PSC register are invalid and do not release the IDLE2 mode. 2. When digital noise elimination is enabled for INTP3, the power save mode cannot be released using INTP3 pin. For details, refer to "Pin Functions" on page 31. 202 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (a) Release by non-maskable interrupt request or unmasked maskable interrupt request The IDLE2 mode is released by a non-maskable interrupt request signal or an unmasked maskable interrupt request signal, regardless of the priority of the interrupt request signal. If the IDLE2 mode is set in an interrupt routine, however, the operation is performed as follows: * If an interrupt request signal having a priority lower than that of the interrupt request currently being serviced is generated, the IDLE2 mode is released, but the interrupt request with the lower priority is not acknowledged. The interrupt request signal itself is held. * If an interrupt request signal (including a non-maskable interrupt request signal) has a priority higher than that of the interrupt request currently being serviced is generated, the IDLE2 mode is released, and this interrupt request signal is acknowledged. Table 4-30 Operation after IDLE2 mode is released by interrupt request signal Releasing Source Interrupt Enabled (EI) Status Interrupt Disabled (DI) Status Non-maskable interrupt request signal Execution branches to the handler address after the specified setup time has elapsed. Maskable interrupt request signal Execution branches to the handler address, or the next instruction is executed after the specified setup time has elapsed. The next instruction is executed after the specified setup time has elapsed. (b) Releasing by RESET input The operation is the same as the normal reset operation. (c) Securing setup time after release of IDLE2 mode Secure the setup time of ROM (flash memory) after releasing the IDLE2 mode. * Releasing by non-maskable interrupt request signal or unmasked maskable interrupt request signal: The setup time is secured by setting the OSTS register. When a source that releases the IDLE2 mode occurs, an internal dedicated timer starts counting in accordance with the setting of the OSTS register. When this counter overflows, the normal operation mode is restored. * Releasing by reset input (RESET pin input or WDT2RES occurrence) The operation is the same as the normal reset operation. The oscillation stabilization time is the default value of the OSTS register, 216 / fX. User's Manual U18743EE1V2UM00 203 Chapter 4 Clock Generator Oscillation waveform Main clock IDLE mode status Interrupt request ROM circuit stops. Figure 4-7 (4) Counting of setup time IDLE2 mode timing STOP mode In the STOP mode, the subclock oscillator continues operating, but the main clock oscillator stops operating. Moreover, clock supply to the CPU and the other on-chip peripheral functions is stopped. As a result, program execution is stopped, and the contents of the internal RAM before the STOP mode was set are retained. Not only the CPU but also the other on-chip peripheral functions stop operating. However, the on-chip peripheral functions that can operate on the subclock or external clock continue operating. The STOP mode can reduce current consumption more than the IDLE2 mode because the operation of the main clock oscillator is stopped. When the subclock oscillator, internal oscillator, and external clock are not used, the current consumption can be substantially reduced with only a leakage current flowing. Entering STOP mode The STOP mode is set when the PSM1 and PSM0 bits of the PSMR register are set to "01" or "11", and the STP bit of the PSC register is set to 1 in the normal operation mode. Insert five or more NOP instructions after the store instruction that manipulates the PSC register to set the STOP mode. STOP mode status Table 4-31 The following table shows the operation status in the STOP mode. Controller status in STOP mode (1/2) Working condition Without Subclock MainOSC (fX) Stops operation SubOSC (fXT) - 240 KHz internal oscillator (fRL) Oscillation enabled 8 MHz internal oscillator (fRH) Stops operation PLL (fPLLO) Stops operation CPU Stops operation Port function Holds status before STOP mode is set 204 User's Manual U18743EE1V2UM00 With Subclock Oscillation enabled Clock Generator Table 4-31 Chapter 4 Controller status in STOP mode (2/2) Working condition Without Subclock Timer/counter With Subclock TAA0 -TAA4 Stops operation Operable if fBRG (clock of dividing Operable if fRL/8, INTWT or fXT is frequency of Prescaler3) is selected as selected as count clock. count clock. TMM0 Watch Timer (WT) Stops operation Watchdog Timer (WDT2) Operable if fRL is selected as count clock. AD convertor Stops operation Serial Interface Operable if fXT is selected as count clock. UARTD0-2 UARTD0: Operable if ASCKD0 is selected input clock UARTD1-2: Operation stops. CSIB0-1 Operable, if SCKBn is selected as input clock. IIC00 Stops operation CAN Controller (CAN0) Stops operation Interrupt Controller Stops operation (But it is possible to leave STOP Mode) Key interrupting function Operable Clock Monitor Stops operation Power-On-Clear circuit Operable Low-Voltage Detector Operable Voltage Regulator Operation continuous Internal data The CPU registers, states, data and all other internal data such as the contents of the internal RAM are retained as they were before STOP mode was set Note 1. If the STOP mode is set while the A/D Converter is operating, the A/D Converter is automatically stopped and starts operating again after the STOP mode is released. However, in that case, the A/D conversion results up to the second conversion after the STOP mode is released are invalid (the third or later conversion results are valid). All the A/D conversion results before the STOP mode was set are invalid. 2. The power consumption in STOP mode is the same, no matter whether the A/D Converter was operating or stopped before the STOP mode was set. Leaving STOP mode The STOP mode is released by a non-maskable interrupt request signal (NMI pin input or INTWDT2 signal), unmasked external interrupt request signal, unmasked internal interrupt request signal of a peripheral function that can operate in the STOP mode, or reset signal. When the STOP mode has been released, the normal operation mode is restored. Note 1. Interrupt request signals that are disabled by the NMI1M, NMI0M, and INTM bits of the PSC register are invalid and do not release the STOP mode. 2. When digital noise elimination is enabled for INTP3, the power save mode cannot be released using INTP3 pin. For details, refer to "Pin Functions" on page 31. (a) Release by non-maskable interrupt request or unmasked maskable interrupt request User's Manual U18743EE1V2UM00 205 Chapter 4 Clock Generator The STOP mode is released by a non-maskable interrupt request signal or an unmasked maskable interrupt request signal, regardless of the priority of the interrupt request signal. If the STOP mode is set in an interrupt routine, however, the operation is performed as follows: * If an interrupt request signal with a priority lower than that the interrupt request currently being serviced is generated, the STOP mode is released, but the interrupt request with the lower priority is not acknowledged. The interrupt request signal itself is held. * If an interrupt request signal (including a non-maskable interrupt request signal) with a priority higher than that of the interrupt request currently being serviced is generated, the STOP mode is released, and this interrupt request signal is acknowledged. Table 4-32 Operation after STOP mode is released by interrupt request signal Releasing Source Interrupt Enabled (EI) Status Interrupt Disabled (DI) Status Non-maskable interrupt request signal Execution branches to the handler address after the specified oscillation stabilization time has elapsed. Maskable interrupt request signal Execution branches to the handler address, or the next instruction is executed after the oscillation stabilization time has elapsed. The next instruction is executed after the oscillation stabilization time has elapsed. (b) Securing setup time after release of STOP mode The main clock / 8MHz internal oscillator stop operating when the STOP mode is set. Therefore, secure the oscillation stabilization time of the clock oscillator(s) after releasing the STOP mode. Releasing by non-maskable interrupt request signal or unmasked maskable interrupt request signal: * The setup time is secured by setting the OSTS register. * When a source that releases the STOP mode occurs, an internal dedicated timer starts counting in accordance with the setting of the OSTS register. When this counter overflows, the normal operation mode is restored. MainOSC wavefrom Main clock STOP mode status Interrupt request STOP mode Figure 4-8 206 OSC start OSC setup time STOP mode timing for main clock operation User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 (c) Releasing by RESET input The operation is the same as the normal reset operation. (5) Subclock operation mode When the subclock operation mode is set, the CPU system clock fVBCLK is changed from the main system clock to the subclock. Subclock can be fXT or fRL. The selection is made by the SUBCLK bit of the option byte 007BH. Check that the CPU system clock has been changed by using the CLS bit of the PCC register. When the MCK bit of the PCC register is set to 1, the operation of the main clock oscillator is stopped. Consequently, the entire system operates on the subclock. In the subclock operation mode, the subclock is used as the CPU system clock, so that the current consumption can be reduced from that in the normal operation mode. In addition, a current consumption close to that in the STOP mode can be achieved by stopping the operation of the main clock oscillator. Entering subclock mode The subclock operation mode is set when the CK3 bit of the PCC register is set to 1 in the normal operation mode. Note 1. Changing the value of the CK2 to CK0 bits of the PCC register is prohibited when the CK3 bit is manipulated (0 to 1 or 1 to 0). Set the CK3 bit by using a bit manipulation instruction. For details of the PCC register, refer to "PCC - Processor clock control register" on page 173. 2. If the following condition is not satisfied, change the CK2 to CK0 bits so as to satisfy the condition and move to subclock operation mode. Internal system clock (fCLK) > subclock (fSC) x 4 Subclock mode status Table 4-33 The following table shows the operation status in subclock mode. Controller status in subclock mode (1/2) Working condition With MainOSC operating MainOSC (fX) Oscillation enabled SubOSC (fXT) Oscillation enabled With MainOSC stopped 240 KHz internal oscillator (fRL) Oscillation enabled 8 MHz internal oscillator (fRH) Oscillation enabled PLL (fPLLO) Operable CPU Operable Port function Settable Timer/counter Stops operationa TAA0 -TAA4 Operable Stops operation TMM0 Operable Operable if fRH/8, fRL/8, INTWT or fXT is selected as count clock. Watch Timer (WT) Operable Operable if fXT is selected as count clock. Watchdog Timer (WDT2) Operable Operable if fRL is selected as count clock. AD convertor Operable Stops operation User's Manual U18743EE1V2UM00 207 Chapter 4 Clock Generator Table 4-33 Controller status in subclock mode (2/2) Working condition With MainOSC operating Serial Interface With MainOSC stopped UARTD0-2 Operable UARTD0: Operable if ASCKD0 is selected input clock UARTD1-2: Operation stops CSIB0-1 Operable Operable if SCKBn input clock is selected as operation clock. IIC00 Operable Stops operation CAN Controller (CAN0) Operable Stops operation Interrupt Controller Operable Key interrupting function Operable Clock Monitor Operable Power-On-Clear circuit Operable Low-Voltage Detector Operable Voltage Regulator Operation continuous Internal data Settable a) Set PLL to stop (PLLCTL.PLLON = 0) when you stop the main clock oscillation circuit. Note 1. When stopping the main clock, be sure to stop the PLL (by clearing the PLLON bit of the PLLCTL register to 0). 2. When the CPU is operating on the subclock and main clock oscillation is stopped, accessing a register in which a wait occurs is disabled. If a wait is generated, it can be released only by RESET. Leaving subclock mode The subclock operation mode is released by clearing the CK3 bit to 0 or by a reset signal. Note 1. Changing the set value of the CK2 to CK0 bits of the PCC register is prohibited when the CK3 bit is manipulated (set the CK3 bit by using a bit manipulation instruction). For details of the PCC register, refer to "PCC Processor clock control register" on page 173. 2. When digital noise elimination is enabled for INTP3, the power save mode cannot be released using INTP3 pin. For details, refer to "Pin Functions" on page 31. When the main clock is stopped (PCC.MCK = 1), clear the MCK bit to 0, secure the oscillation stabilization time of the main clock by software, and then clear the CK3 bit to 0. When the subclock operation mode is released, the normal operation mode is restored. (6) Sub-IDLE mode In the sub-IDLE mode, the clock oscillator continues operating, but clock supply to the CPU, flash memory, and the other on-chip peripheral functions is stopped. As a result, program execution is stopped, and the contents of the internal RAM before the sub-IDLE mode was set is retained. Not only the CPU but also 208 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 the other on-chip peripheral functions stop operating. However, the on-chip peripheral functions that can operate on the subclock continue operating. The sub-IDLE mode can reduce current consumption more than the subclock operation mode because the operations of the CPU, flash memory, and other on-chip peripheral functions are stopped. If the sub-IDLE mode is set after the main clock is stopped, a current consumption close to that in the STOP mode can be achieved. Entering sub-IDLE mode The sub-IDLE mode is set when the PSM1 and PSM0 bits of the PSMR register are set to "10" and the STP bit of the PSC register is set to 1 while the processor is in the subclock operation mode. Note Insert five or more NOP instructions after the store instruction that manipulates the PSC register to set the sub-IDLE mode. Sub-IDLE mode status Table 4-34 The following table shows the operation status in sub-IDLE mode. Controller status in sub-IDLE mode Working condition When main clock oscillator oscillates When main clock oscillator stops 240 KHz internal oscillator (fRL) Oscillation enabled 8 MHz internal oscillator (fRH) Oscillation enabled PLL (fPLLO) Operable CPU Stops operation Port function The settings of the previous mode are maintained Timer/counter Stops operationa TAA0 -TAA4 Stops operation TMM0 Operable if fRH/8, fRL/8 or fXT is selected as count clock. Watch Timer (WT) Operable Operable if fXT is selected as count clock. Watchdog Timer (WDT2) Operable Operable if fRL is selected as count clock. AD convertor Stops operation Serial Interface UARTD0-2 UARTD0: Operable, if ASCKD0 is selected as input clock UARTD1-2: Operation stops CSIB0-1 Operable if SCKBn input clock is selected as operation clock. IIC00 Stops operation CAN Controller (CAN0-3) Stops operation Interrupt Controller Stops operation (but it is possible to leave Sub Idle Mode) Key interrupting function Operable Clock Monitor Operable Power-On-Clear circuit Operable Low-Voltage Detector Operable Voltage Regulator Operation continuous Internal data The CPU registers, statuses, data and all other internal data such as the contents of the internal RAM are retained as they were before Sub IDLE mode was set a) Stop the PLL (PLLCTL.PLLON = 0) when you stop the main clock oscillation circuit. User's Manual U18743EE1V2UM00 209 Chapter 4 Clock Generator Leaving sub-IDLE mode The sub-IDLE mode is released by a non-maskable interrupt request signal (NMI pin input or INTWDT2 signal), unmasked external interrupt request signal, unmasked internal interrupt request of a peripheral function that can operate in the sub-IDLE mode, or reset signal. The PLL returns to the operation status before the sub-IDLE mode was set. When the sub-IDLE mode is released by an interrupt request signal, the subclock operation mode is restored. When the sub-IDLE mode is released by RESET, the normal operation mode is restored. Note 1. Interrupt request signals that are disabled by the NMI1M, NMI0M, and INTM bits of the PSC register are invalid and do not release the sub-IDLE mode. 2. When digital noise elimination is enabled for INTP3, the power save mode cannot be released using INTP3 pin. For details, refer to "Pin Functions" on page 31. (a) Release by non-maskable interrupt request or unmasked maskable interrupt request The sub-IDLE mode is released by a non-maskable interrupt signal or an unmasked maskable interrupt request signal, regardless of the priority of the interrupt request signal. If the sub-IDLE mode is set in an interrupt routine, however, the operation is performed as follows: * Interrupt request signals that are set (disabled) by the NMI1M, NMI0M, and INTM bits of the PSC register are invalid and do not release the sub-IDLE mode. * If an interrupt request signal having a priority lower than that of the interrupt request currently being serviced is generated, the sub-IDLE mode is released, but the interrupt request with the lower priority is not acknowledged. The interrupt request signal itself is held. * If an interrupt request signal (including a non-maskable interrupt request signal) having a priority higher than that of the interrupt request currently being serviced is generated, the sub-IDLE mode is released, and this interrupt request signal is acknowledged. Table 4-35 Operation after sub-IDLE mode is released by interrupt request signal Releasing Source Interrupt Enabled (EI) Status Non-maskable interrupt request signal Execution branches to the handler address. Maskable interrupt request signal Execution branches to the handler address, or the next instruction is executed. Interrupt Disabled (DI) Status The next instruction is executed. (b) Releasing by RESET input The operation is the same as the normal reset operation. 210 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.4.4 Available clocks in power save modes The following table gives an overview of the clock signals available in the various stand-by modes. Table 4-36 Clock operation in power save modes fX/fPLLI fXT fRL fRH Note2 Note2 Note2 Note2 fPLL fPCL fXX fXP1 Reset period x O x x x x x x From reset release to 8 MHz internal oscillator setup x O O O x O x Run enable O enable O enable O HALT mode enable O enable O enable IDLE1 mode enable O enable O STOP mode x O enable From STOP release to oscillation stabilization enable O enable Run O O HALT mode O IDLE1 mode Operation status 8 MHz internal oscillator fVBCLK fCPU fXP2 fXC x x x x x x x O O O O enable O O O x O enable enable x x x x O x x x x x x x x x O x O x x x O enable enable enable enable O O O O O O O enable enable enable O O O x O O O O enable enable enable x x x x O x IDLE2 mode O O enable enable x x x x x x x From IDLE2 release to setup O O enable enable x x x x x x x STOP mode x O enable x x x x x x x From STOP release to oscillation stabilization O O enable enable x x x x x x x Run O O enable enable O O O O O O O HALT mode O O enable enable O O O O x O O IDLE1 mode O O enable enable O x x x x O x IDLE2 mode O O enable enable x x x x x x x From IDLE2 release to setup O O enable enable x x x x x x x STOP mode x O enable x x x x x x x From STOP release to oscillation stabilization O O enable enable x x x x x x x Run enable O enable enable enable enable enable O O IDLE mode enable O enable enable enable x x Run enable O O enable enable enable enable O O HALT mode enable O O enable enable x x Run - O O enable - enable enable O O enable enable HALT mode - O O enable - enable enable O x enable enable Note1 MainOSC Note1 PLL/ Note1 SubOSC Note1 240 KHz internal oscillatorSub Note1 240 KHz internal oscillatorSecurity Note1 User's Manual U18743EE1V2UM00 x x x x x x enable enable x x enable enable x x 211 Chapter 4 Clock Generator O: Operating x: Stopped Enable: Operation enable (by control register and option bytes setting) Note 1. The working conditions are the following: - 8 MHz internal oscillator: 8 MHz internal oscillator clock operation - MainOSC: MainOSC clock operation - PLL: PLL clock operation - SubOSC: SubOSC clock operation - 240 KHz internal oscillatorSub: 240 KHz internal oscillator clock operation for Sub - 240 KHz internal oscillatorSecurity: 240 KHz internal oscillator clock operation for Security 2. The clock signals are: 212 fX: MainOSC clock fXT: SubOSC clock fRL: 240 KHz internal oscillator clock fRH: 8 MHz internal oscillator clock fPLL: PLL output clock fPCL: Programmable clock output fXX: Main system clock fVBCLK: CPU system clock fCPU: CPU core clock fXP1: Peripheral clock (Prescaler1) fXP2: Clock for UARTD, TAA fXC: Clock for CAN User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.4.5 Power save mode activation In the following procedures are described how to securely entering a power save mode. (1) HALT mode For entering the HALT mode proceed as follows: 1. Mask all interrupts which shall not have wake-up capability by xxIC.xxMK = 0 and discard all possibly pending interrupts by xxIC.xxIF = 0. 2. Unmask all interrupts which shall have wake-up capability by xxIC.xxMK = 1. 3. Execute the "halt" instruction. (2) IDLE1, IDLE2 and STOP mode For entering these power save mode proceed as follows: 1. In case maskable interrupts shall be used for wake-up unmask these interrupts by IMRm.xxMK = 0 (refer to "IMRm - Interrupt mask registers" on page 240). 2. Mask all other interrupts, i.e. - none wake-up capable interrupts - wake-up capable interrupts which shall not be used for wake-up by IMRm.xxMK = 1. This prevents the power save mode entry procedure from being interrupted by these interrupts. 3. It is recommended to disable interrupt acknowledgement by the "di" instruction. 4. Specify the desired power save mode in PSM.PSM[1:0]. 5. Enable writing to the write-protected register PSC by writing to PRCMD. 6. Write to PSC for specifying permitted wake-up events and activate the power save mode by setting PSC.STP to 1. Example The following example shows how to initialize and enter a IDLE1, IDLE2 or STOP power save mode. First the desired power save mode is specified (IDLE2 mode in this example, that means PSMR.PSM[1:0] = 10B). The PSC register is a write-protected register, and the PRCMD register is the corresponding write-enable register. PRCMD has to be written immediately before writing to PSC. User's Manual U18743EE1V2UM00 213 Chapter 4 Clock Generator In this example, maskable interrupts are permitted to leave the power save mode. 3. 4. 5. 6. 7. 8. 9. 10. // xxIC.xxMK = 0 // xxIC.xxMK = 1 di mov 0x02,r10 st.b 10,PSMR[r0] mov 0x62,r10 st.b r10,PRCMD[r0] st.b r10,PSC[r0] 11. 12. 13. 14. 15. 16. 17. 18. nop nop nop nop nop // xxIC.xxIF = 0 ei // mask all none wake-up interrupts // unmask all wake-up interrupts // PSMR.PSM[1:0] = 10B: IDLE2 mode // enable write to PSC // wake up by maskable interrupts // and enter power save mode // after wake-up // discard all unwanted pending interrupts Be aware of the following notes when entering power save mode using the above sequence: Note 1. It is recommended to disable maskable interrupt acknowledgement in general by the "di" instruction (step 3.) to prevent any pending interrupt from being served during the power save mode set-up procedure. This makes it also possible to completely control the process after wake-up, since no pending interrupt will be unintentional acknowledged. Before enabling interrupt acknowledgement by the "ei" instruction (step 16.) after wake-up, all unwanted interrupts can be discarded by setting xxIC.xxIF = 0 (step 15.). Since the wake-up capability of the unmasked wake-up interrupts is not affected by "di", such interrupts shall be masked (step 1.) by IMRm.xxMK = 1. 2. The store instruction to PRCMD will not allow to acknowledge any interrupt until processing of the subsequent instruction is complete. That means, an interrupt will not be acknowledged before the store to PSC. This presupposes that both store instructions are performed consecutively, as shown in the above example. If another instruction is placed between steps 7 and 8, an interrupt request may be acknowledged in between, and the power save mode may not be entered. However if the "di" instruction was executed before (step 3.) none interrupt will be acknowledged anyway. 3. At least 5 "nop" instructions must follow the power down mode setting, that means after the write to PSC. The microcontroller requires this time to enter power down mode. 4. Any data can be written to the PRCMD register. In the example the same data is written, minimizing the number of used registers. 5. No special sequence is required for reading the PSC register. 214 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.4.6 Controlling the PLL Using the PLL After the RESET signal has been released, the PLL has to be started by PLLCTL.PLLON = 1, after the main oscillator has stabilized (OSTC.MSTS = 1). Since the default mode is the clock-through mode (PLLCTL.SELPLL = 0), select the PLL mode (PLLCTL.SELPLL = 1). * To operate the PLL from the stopped status, set PLLCTL.PLLON = 1, and then set PLLCTL.SELPLL = 1 after the LOCKR.LOCK bit = 0 (the lockup time can be counted by setting the lockup time to the PLLS register and monitoring the LOCK flag of the LOCKR register). * To stop the PLL, first select the clock-through mode (PLLCTL.SELPLL = 0), wait for 8 clocks or more, and then stop the PLL (set PLLCTL.PLLON = 0). When shifting to the IDLE2 or STOP mode while remaining in the PLL operation mode, set the OSTS register as follows: * STOP mode: Oscillation stabilization time > PLL lockup time * IDLE2 mode: Setup time > PLL lockup time When shifting to the IDLE1 mode, the PLL does not stop. Stop the PLL if necessary. Not using the PLL The clock-through mode (PLLCTL.SELPLL = 0) is selected after the RESET signal has been released. The PLL is stopped by default. 4.4.7 Watch Dog Timer Clock After reset release, the Watchdog Timer WDT2 is operating on the 240 KHz internal oscillator (fRL/8 = 30 KHz approx.). When the MainOSC has stabilized, the Watchdog Timer can be clocked by the MainOSC (fX/128). 4.4.8 CLKOUT function The clock output function is used to output the CPU system clock (fVBCLK) from the CLKOUT pin. The status of the CLKOUT pin is the same as the CPU system clock. The pin can output the clock when it is in the operable status. It outputs a low level in the stopped status. User's Manual U18743EE1V2UM00 215 Chapter 4 Clock Generator 4.4.9 Operation of Prescaler3 Prescaler3 generates the clock fBRG by dividing the main oscillator output signal fX. (1) Description Prescaler3 consists of a clock divider, a counter, and a comparator. Figure 4-9 (2) Prescaler3 Block Diagram Calculation The relation between the main oscillator clock (fX), prescaler clock divider selection PRSM0.BGCS0[1:2], PRSCM0 compare register value, and output clock fBRG is as follows: fBRG = fX / (2m x N x 2) where fBRG = output clock frequency fX = input clock frequency m = BGCS0[1:0] value (0 to 3) N = PRSCM0 register value (1 to FFH). If PRSCM0 = 00H: N = 256 Example If fX = 4 MHz m=0 N = 3DH then fBRG = 32,787 KHz 216 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 4.4.10 Operation of the Clock Monitor The Clock Monitor samples the main clock by using the on-chip 240 KHz internal oscillator. It generates a reset request signal when the oscillation of the main clock has stopped. (1) Description The functional block diagram is shown below. MainOSC fX RESCLM (lnternal RESET signal) 240 KHz internal oscillator fRL Enable/disable CLM.CLME Figure 4-10 Clock Monitor Block Diagram The Clock Monitor samples the main oscillator signal fX. The Clock Monitor is clocked by the on-chip 240 KHz internal oscillator (fRL). The RESCLM reset signal is generated when the MainOSC clock fails. Table 4-37 Operation status of Clock Monitor (when CLM.CLME Bit = 1, during internal oscillator operation) CPU system clock fVBCLK Operation mode Status of MainOSC Status of internal oscillator Clock Status of Clock Monitor Main clock HALT mode Oscillates Oscillatesa Operatesb IDLE1 mode, IDLE2 mode Oscillates Oscillatesa Operatesb STOP mode Stops Oscillatesa Stops Operatesb Subclock (MCK bit of PCC register = 0) Sub-IDLE mode Oscillates Oscillatesa Subclock (MCK bit of PCC register = 1) Sub-IDLE mode Stops Oscillatesa Stops During reset - Stops Stops Stops a) b) Internal oscillator can be stopped by setting the RSTOP bit of the RCM register to 1 only when 'internal oscillator can be stopped' is specified by an option function. The Clock Monitor is stopped when the internal oscillator is stopped. User's Manual U18743EE1V2UM00 217 Chapter 4 Clock Generator (2) Start and stop The Clock Monitor operation must be enabled by setting bit CLM.CLME to 1. Once this bit has been set, it cannot be cleared to 0 by any means other than reset. The Clock Monitor is automatically started as soon as the main oscillator is stable, indicated by OSTC.MSTS = 1. The Clock Monitor automatically stops under the following conditions: * While oscillation stabilization time is being counted after STOP mode is released * When the main clock is stopped (PCC.MCK bit = 1 during subclock operation, or PCC.CLS bit = 0 during main clock operation) * When the sampling clock is stopped (240 KHz internal oscillator) * When the CPU operates with 8 MHz internal oscillator * When the CPU operates with 240 KHz internal oscillator (3) Operation when main clock oscillation is stopped (CLME bit = 1) If oscillation of the main clock is stopped when the CLME bit = 1, an internal reset signal is generated as shown in the following figure. Four internal oscillator clocks Main clock Internal oscillator clock Internal reset signal Figure 4-11 (4) When oscillation of main clock is stopped Operation in STOP mode or after STOP mode is released If the STOP mode is set with the CLME bit = 1, the monitor operation is stopped in the STOP mode and while the oscillation stabilization time is being counted. After the oscillation stabilization time, the monitor operation is automatically started. 218 User's Manual U18743EE1V2UM00 Clock Generator Chapter 4 CPU Normal operation operation Software STOP Oscillation stabilization time Normal operation Main clock Oscillation stops Oscillation stabilization time (set by OSTS register) Internal oscillator clock CLME Clock monitor status During monitor Figure 4-12 (5) Monitor stops During monitor Operation in STOP mode or after STOP mode is released Operation when main clock is stopped During subclock operation (CLS bit of the PCC register = 1) or when the main clock is stopped by setting the MCK bit of the PCC register to 1, the monitor operation is stopped until the main clock operation is started (CLS bit of PCC register = 0). The monitor operation is automatically started when the main clock operation is started. Subclock operation CPU operation PCCMCK bit = 1 Main clock operation Oscillation stabilization time count by software Main clock Oscillation stops Oscillation stabilization time (set by OSTS register) Internal oscillator clock CLME Clock monitor status During monitor Figure 4-13 Monitor stops Monitor stops During monitor Operation When Main Clock Is Stopped (Arbitrary) User's Manual U18743EE1V2UM00 219 Chapter 4 Clock Generator (6) Operation during and after power save modes Main oscillator stopped If the main oscillator is stopped, the Clock Monitor changes to stand-by. When the main oscillator is restarted after power save mode release, the Clock Monitor restarts automatically. Internal oscillator stopped When the 240 KHz internal oscillator is stopped, the Clock Monitor's operation is suspended. Operation is automatically resumed as soon as the internal oscillator is restarted. 220 User's Manual U18743EE1V2UM00 Chapter 5 Interrupt Controller (INTC) This controller is provided with a dedicated Interrupt Controller (INTC) for interrupt servicing and can process a large amount of maskable and two nonmaskable interrupt requests. An interrupt is an event that occurs independently of program execution, and an exception is an event whose occurrence is dependent on program execution. Generally, an exception takes precedence over an interrupt. This controller can process interrupt requests from the on-chip peripheral hardware and external sources. Moreover, exception processing can be started by the TRAP instruction (software exception) or by generation of an exception event (i.e. fetching of an illegal opcode) (exception trap). Eight levels of software-programmable priorities can be specified for each interrupt request. Starting of interrupt servicing takes no fewer than 5 system clocks after the generation of an interrupt request. 5.1 Features * Interrupts - Non-maskable interrupts: 2 sources - Maskable interrupts: Maskable interrupts V850ES/FE3-L V850ES/FF3-L V850ES/FG3-L Internal 39 42 External 8 11 - 8 levels of programmable priorities (maskable interrupts) - Multiple interrupt control according to priority - Masks can be specified for each maskable interrupt request - Noise elimination, edge detection and valid edge specification, level detection for external interrupt request signals - Wake-up capable (analogue noise elimination for external interrupt request signals) * Exceptions - Software exceptions: 2 channels with each 16 sources - Exception traps: 2 sources (illegal opcode exception and debug trap) User's Manual U18743EE1V2UM00 221 Chapter 5 Interrupt Controller (INTC) Note 1. Default priority: The priority order when two or more maskable Interrupt/Exception Source Type Control Register Name Generating Source Reset RESET - Reset input by internal source Non- maskable NMI - NMI pin valid edge input INTWDT2 - WDT2 overflow Software exception TRAP0n - TRAP instruction - TRAP instruction (n = 0 to F H ) TRAP1n (n = 0 to F H ) Default Exception Generating Priority Code Unit Handler Address Restored PC RESET - 0000H 00000000H undef. Pin - 0010H 00000010H nextPC WDT2 - 0020H 00000020H nextPC - - 004nH 00000040H nextPC - - 005nH 00000050H nextPC - - 0060H 00000060H nextPC Exception trap ILGOP/ DBG0 - Illegal opcode/DBTRAP instruction Maskable INTLVIL LVILIC Low voltage detection (voltage falling below reference level) POCLVI 0 0080H 00000080H nextPC Low voltage detection (voltage rising above reference level) POCLVI 1 0090H 00000090H nextPC INTLVIH 222 LVIHIC INTP0 PIC0 External interrupt 0 Pin 2 00A0H 000000A0H nextPC INTP1 PIC1 External interrupt 1 Pin 3 00B0H 000000B0H nextPC INTP2 PIC2 External interrupt 2 Pin 4 00C0H 000000C0H nextPC INTP3 PIC3 External interrupt 3 Pin 5 00D0H 000000D0H nextPC INTP4 PIC4 External interrupt 4 Pin 6 00E0H 000000E0H nextPC INTP5 PIC5 External interrupt 5 Pin 7 00F0H 000000F0H nextPC INTP6 PIC6 External interrupt 6 Pin 8 0100H 00000100H nextPC INTP7 PIC7 External interrupt 7 Pin 9 0110H 00000110H nextPC INTTAA0OV TAA0OVIC TAA0 overflow TAA0 15 0170H 00000170H nextPC INTTAA0CC0 TAA0CCIC0 TAA0 capture 0 / compare 0 match TAA0 16 0180H 00000180H nextPC INTTAA0CC1 TAA0CCIC1 TAA0 capture 1 / compare 1 match TAA0 17 0190H 00000190H nextPC INTTAA1OV TAA1OVIC TAA1 overflow TAA1 18 01A0H 000001A0H nextPC INTTAA1CC0 TAA1CCIC0 TAA1 capture 0 / compare 0 match TAA1 19 01B0H 000001B0H nextPC INTTAA1CC1 TAA1CCIC1 TAA1 capture 1 / compare 1 match TAA1 20 01C0H 000001C0H nextPC INTTAA2OV TAA2OVIC TAA2 overflow TAA2 21 01D0H 000001D0H nextPC INTTAA2CC0 TAA2CCIC0 TAA2 capture 0 / compare 0 match TAA2 22 01E0H 000001E0H nextPC INTTAA2CC1 TAA2CCIC1 TAA2 capture 1 / compare 1 match TAA2 23 01F0H 000001F0H nextPC INTTAA3OV TAA3OVIC TAA3 overflow TAA3 24 0200H 00000200H nextPC INTTAA3CC0 TAA3CCIC0 TAA3 capture 0 / compare 0 match TAA3 25 0210H 00000210H nextPC INTTAA3CC1 TAA3CCIC1 TAA3 capture 1 / compare 1 match TAA3 26 0220H 00000220H nextPC INTTAA4OV TAA4OVIC TAA4 overflow TAA4 27 0230H 00000230H nextPC INTTAA4CC0 TAA4CCIC0 TAA4 capture 0 / compare 0 match TAA4 28 0240H 00000240H nextPC INTTAA4CC1 TAA4CCIC1 TAA4 capture 1 / compare 1 match TAA4 29 0250H 00000250H nextPC INTTM0EQ0 TM0EQIC0 TMM0 compare match TMM0 30 0260H 00000260H nextPC INTCB0R CB0RIC CSIB0 reception completion / reception error CSIB0 31 0270H 00000270H nextPC INTCB0T CB0TIC CSIB0 consecutive transmission write enable CSIB0 32 0280H 00000280H nextPC User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 Interrupt/Exception Source Type Maskable a) Control Register Name Generating Source Default Exception Generating Priority Code Unit Handler Address Restored PC INTCB1R CB1RIC CSIB1 reception completion / reception error CSIB1 33 0290H 00000290H nextPC INTCB1T CB1TIC CSIB1 consecutive transmission write enable CSIB1 34 02A0H 000002A0H nextPC INTUD0S UD0SIC UARTD0 status interrupt UARTD0 35 02B0H 000002B0H nextPC INTUD0R UD0RIC UARTD0 reception completion UARTD0 36 02C0H 000002C0H nextPC INTUD0T UD0TIC UARTD0 consecutive transmission enable UARTD0 37 02D0H 000002D0H nextPC INTUD1S UD1SIC UARTD1 status interrupt UARTD1 38 02E0H 000002E0H nextPC INTUD1R UD1RIC UARTD1 reception completion UARTD1 39 02F0H 000002F0H nextPC INTUD1T UD1TIC UARTD1 consecutive transmission enable UARTD1 40 0300H 00000300H nextPC INTIIC0 IIC0IC IIC0 transfer completion IIC0 41 0310H 00000310H nextPC INTAD ADIC A/D conversion completion AD 42 0320H 00000320H nextPC INTC0ERR C0ERRIC CAN0 error CAN0 43 0330H 00000330H nextPC INTC0WUP C0WUPIC CAN0 wake-up CAN0 44 0340H 00000340H nextPC INTC0REC C0RECIC CAN0 reception CAN0 45 0350H 00000350H nextPC INTC0TRX C0TRXIC CAN0 transmission CAN0 46 0360H 00000360H nextPC INTKR KRIC Key return interrupt KR 51 03B0H 000003B0H nextPC INTWTI WTIIC Watch Timer interval WT 52 03C0H 000003C0H nextPC INTWT WTIC Watch Timer reference time WT 53 03D0H 000003D0H nextPC Reserved - - - 54 03E0H 000003E0H nextPC INTFL FLIC Flash programming completion FLASH 55 03F0H 000003F0H nextPC INTP8 a PIC8 External interrupt 8 Pin 56 0400H 00000400H nextPC INTP9 a PIC9 External interrupt 9 Pin 57 0410H 00000410H nextPC INTP10 a PIC10 External interrupt 10 Pin 58 0420H 00000420H nextPC INTUD2S a UD2SIC UARTD2 status interrupt UARTD2 64 0480H 00000480H nextPC INTUD2R a UD2RIC UARTD2 reception completion UARTD2 65 0490H 00000490H nextPC INTUD2T a UD2TIC UARTD2 consecutive transmission enable UARTD2 66 04A0H 000004A0H nextPC not available for V850ES/FE3-L, V850ES/FF3-L interrupt requests are generated at the same time. The highest priority is 0. 2. Restored PC: The value of the PC saved to EIPC or FEPC when interrupt/exception processing is started. However, the value of the PC saved when an interrupt is acknowledged during division (DIV, DIVH, DIVU, DIVHU) instruction execution is the value of the PC of the current instruction (DIV, DIVH, DIVU, DIVHU). 3. nextPC: The PC value that starts the processing following interrupt/exception processing. 4. The execution address of the illegal instruction when an illegal opcode exception occurs is calculated by (Restored PC - 4). User's Manual U18743EE1V2UM00 223 Chapter 5 Interrupt Controller (INTC) 5.2 Non-Maskable Interrupts A non-maskable interrupt request is acknowledged unconditionally, even when interrupts are in the interrupt disabled (DI) status. Non-maskable interrupts of this microcontroller are available for the following requests: * NMI: NMI pin input * INTWDT2: Non-maskable Watchdog Timer interrupt request When the valid edge, specified by the INTR0.INTR02 and INTF0.INTF02, is detected atthe NMI pin, the NMI interrupt occurs. The Watchdog Timer interrupt request is only effective as non-maskable interrupt if WDTM2.WDM2[1:0] = 01B is chosen in the Watchdog Timer mode register. If multiple non-maskable interrupts are generated at the same time, the highest priority servicing is executed according to the following priority order (the lower priority interrupt is ignored): INTWDT2 > NMI Note that if a NMI from port pin or INTWDT2 request is generated while NMI from port pin is being serviced, the service is executed as follows. (1) If a NMI is generated while NMI is being serviced The new NMI request is held pending regardless of the value of the PSW.NP bit. The pending NMIVC request is acknowledged after servicing of the current NMI request has finished (after execution of the RETI instruction). (2) If a INTWDT2 request is generated while NMI is being serviced If the PSW.NP bit remains set (1) while NMI is being serviced, the new INTWDT2 request is held pending. The pending INTWDT2 request is acknowledge after servicing of the current NMI request has finished (after execution of the RETI instruction). If the PSW.NP bit is cleared (0) while NMI is being serviced, the newly generated INTWDT2 request is executed (NMI servicing is halted). Caution 1. Although the values of the PC and PSW are saved to an NMI status save register (FEPC, FEPSW) when a non-maskable interrupt request is generated, only the NMI can be restored by the RETI instruction at this time. Because INTWDT2 cannot be restored by the RETI instruction, the system must be reset after servicing this interrupt. 2. If PSW.NP is cleared to 0 by the LDSR instruction during non-maskable interrupt servicing, a NMI interrupt afterwards cannot be acknowledged correctly. 224 User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 NMI and INTWDT2 requests generated simultaneously Main routine INTWDT2 servicing NMI and INTWDT2 requests (generated simultaneously) Figure 5-1 System reset Example of non-maskable interrupt request acknowledgement operation: multiple NMI requests generated at the same time User's Manual U18743EE1V2UM00 225 Chapter 5 Interrupt Controller (INTC) NMI being serviced NMI NMI request generated during NMI servicing NMI NMI request generated during NMI servicing INTWDT2 INTWDT2 request generated during NMI servicing (NP = 1 retained before NMI1 request) Main routine Main routine NMI servicing NMI servicing NMI request (Held pending) NMI request INTWDT2 request (Held pending) NMI request INTWDT2 servicing Servicing of pending NMI System reset INTWDT2 request generated during NMI servicing (NP=0 set before INTWDT2 request) Main routine NMI servicing servicing NP = 0 NMI request request System reset INTWDT2 request generated during NMI servicing (NP=0 set after INTWDT2 request) Main routine INTWDT2 servicing NMI servicing (Held INTWDT2 pending) request NMI request NP = 0 System reset INTWDT2 NMI request generated during INTWDT2 servicing NMI request generated during INTWDT2 servicing Main routine Main routine INTWDT2 servicing INTWDT2 servicing NMI request INTWDT2 request Figure 5-2 226 INTWDT2 request (Invalid) (Invalid) INTWDT2 request System reset System reset Example of non-maskable interrupt request acknowledgement operation: NMI request generated during NMI servicing User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 5.2.1 Operation If a non-maskable interrupt is generated, the CPU performs the following processing, and transfers control to the handler routine: 1. 2. 3. 4. 5. Saves the restored PC to FEPC. Saves the current PSW to FEPSW. Writes exception code 0010H to the higher halfword (FECC) of ECR. Sets the NP and ID bits of the PSW and clears the EP bit. Sets the handler address corresponding to the non-maskable interrupt to the PC, and transfers control. The processing configuration of a non-maskable interrupt is shown in Figure 5-3. NMI input INTC acknowledgement Non-maskable interrupt request CPU processing PSW.NP 1 0 Restored PC FEPC PSW FEPSW ECR.FECC Exception code 1 PSW.NP 0 PSW.EP 1 PSW.ID NMI-Handler PC address Interrupt service Figure 5-3 Interrupt request pending Processing configuration of non-maskable interrupt User's Manual U18743EE1V2UM00 227 Chapter 5 Interrupt Controller (INTC) 5.2.2 Restore (1) NMI Execution is restored from the non-maskable interrupt (NMI) processing by the RETI instruction. When the RETI instruction is executed, the CPU performs the following processing, and transfers control to the address of the restored PC. 1. Restores the values of the PC and the PSW from FEPC and FEPSW, respectively, because the EP bit of the PSW is 0 and the NP bit of the PSW is 1. 2. Transfers control back to the address of the restored PC and PSW. Figure 5-4 illustrates how the RETI instruction is processed. RETI instruction 1 PSW.EP 0 PSW.NP 1 0 PC PSW EIPC EIPSW PC PSW FEPC FEPSW Original processing restored Figure 5-4 Caution Note 228 RETI instruction processing When the PSW.EP bit and PSW.NP bit are changed by the LDSR instruction during non-maskable interrupt processing, in order to restore the PC and PSW correctly during recovery by the RETI instruction, it is necessary to set PSW.EP back to 0 and PSW.NP back to 1 using the LDSR instruction immediately before the RETI instruction. The solid line indicates the CPU processing flow. User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) (2) Chapter 5 INTWDT2 Restoring by RETI instruction is not possible. Perform a system reset after interrupt servicing. 5.2.3 Non-maskable interrupt status flag (NP) The NP flag is a status flag that indicates that non-maskable interrupt (NMI) processing is under execution. This flag is set when an NMI interrupt has been acknowledged, and masks all interrupt requests and exceptions to prohibit multiple interrupts from being acknowledged. 31 PSW 0 8 6 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NP EP ID Bit position Bit name 7 NP 7 4 3 2 1 0 Initial value SAT CY OV S Z 00000020H Function Indicates whether NMI interrupt processing is in progress. 0: No NMI interrupt processing 1: NMI interrupt currently being processed 5.2.4 NMI control The NMI can be configured to generate a non-maskable interrupt upon a rising, falling or both edges at the NMI pin. To enable respectively disable the NMI and to configure the edge refer to "External Interrupts Edge Detection Configuration" on page 244. User's Manual U18743EE1V2UM00 229 Chapter 5 Interrupt Controller (INTC) 5.3 Maskable Interrupts Maskable interrupt requests can be masked by interrupt control registers. This microcontroller has up to 52 maskable interrupt sources. If two or more maskable interrupt requests are generated at the same time, they are acknowledged according to the default priority. In addition to the default priority, eight levels of priorities can be specified by using the interrupt control registers (programmable priority control). When an interrupt request has been acknowledged, the acknowledgement of other maskable interrupt requests is disabled and the interrupt disabled (DI) status is set. When the EI instruction is executed in an interrupt processing routine, the interrupt enabled (EI) status is set, which enables servicing of interrupts having a higher priority than the interrupt request in progress (specified by the interrupt control register). Note that only interrupts with a higher priority will have this capability; interrupts with the same priority level cannot be nested. However, if multiple interrupts are executed, the following processing is necessary. 1. Save EIPC and EIPSW in memory or a general-purpose register before executing the EI instruction. 2. Execute the DI instruction before executing the RETI instruction, then reset EIPC and EIPSW with the values saved in (1). 5.3.1 Operation If a maskable interrupt occurs, the CPU performs the following processing, and transfers control to a handler routine: 1. 2. 3. 4. 5. Saves the restored PC to EIPC. Saves the current PSW to EIPSW. Writes an exception code to the lower halfword of ECR (EICC). Sets the ID bit of the PSW and clears the EP bit. Sets the handler address corresponding to each interrupt to the PC, and transfers control. The processing configuration of a maskable interrupt is shown in Figure 5-5. 230 User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 INT input INTC accepted xxIF = 1 No Yes xxMK = 0 Yes Priority higher than that of interrupt currently processed? No Is the interrupt mask released? No Yes Priority higher than that of other interrupt request? No Yes Highest default priority of interrupt requests with the same priority? No Yes Maskable interrupt request Interrupt request pending CPU processing PSW.NP 1 0 PSW.ID 1 0 EIPC EIPSW ECR.EICC PSW.EP PSW.ID PC restored PC PSW exception code 0 1 handler address Interrupt request pending Interrupt processing Figure 5-5 Note Maskable interrupt processing For the ISPR register, see "ISPR - In-service priority register" on page 242. An INT input masked by the Interrupt Controllers and an INT input that occurs while another interrupt is being processed (when PSW.NP = 1 or PSW.ID = 1) are held pending internally by the Interrupt Controller. In such case, if the interrupts are unmasked, or when PSW.NP = 0 and PSW.ID = 0 as set by the RETI and LDSR instructions, input of the pending INT starts the new maskable interrupt processing. User's Manual U18743EE1V2UM00 231 Chapter 5 Interrupt Controller (INTC) 5.3.2 Restore Recovery from maskable interrupt processing is carried out by the RETI instruction. When the RETI instruction is executed, the CPU performs the following steps, and transfers control to the address of the restored PC. 1. Restores the values of the PC and the PSW from EIPC and EIPSW because the EP bit of the PSW is 0 and the NP bit of the PSW is 0. 2. Transfers control to the address of the restored PC and PSW. Figure 5-6 illustrates the processing of the RETI instruction. RETI instruction 1 PSW.EP 0 PSW.NP 1 0 PC PSW Corresponding bit of ISPRNote EIPC EIPSW 0 PC PSW FEPC FEPSW Restores original processing Figure 5-6 Note RETI instruction processing 1. For the ISPR register, see "ISPR - In-service priority register" on page 242. 2. The solid lines show the CPU processing flow. Caution 232 When the PSW.EP bit and the PSW.NP bit are changed by the LDSR instruction during maskable interrupt processing, in order to restore the PC and PSW correctly during recovery by the RETI instruction, it is necessary to set PSW.EP back to 0 and PSW.NP back to 0 using the LDSR instruction immediately before the RETI instruction. User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 5.3.3 Priorities of maskable interrupts This microcontroller provides multiple interrupt servicing in which an interrupt is acknowledged while another interrupt is being serviced. Multiple interrupts can be controlled by priority levels. There are two types of priority level control: control based on the default priority levels, and control based on the programmable priority levels that are specified by the interrupt priority level specification bit (xxPRn) of the interrupt control register (xxICn). When two or more interrupts having the same priority level specified by the xxPRn bit are generated at the same time, interrupts are serviced in order depending on the priority level allocated to each interrupt request type (default priority level) beforehand. For more information, refer to the interrupt/exception source list table. The programmable priority control customizes interrupt requests into eight levels by setting the priority level specification flag. Note that when an interrupt request is acknowledged, the ID flag of PSW is automatically set to 1. Therefore, when multiple interrupts are to be used, clear the ID flag to 0 beforehand (for example, by placing the EI instruction in the interrupt service program) to set the interrupt enable mode. User's Manual U18743EE1V2UM00 233 Chapter 5 Interrupt Controller (INTC) Main routine Processing of a EI Processing of b EI Interrupt request b (level 2) Interrupt request a (level 3) Interrupt request b is acknowledged because the priority of b is higher than that of a and interrupts are enabled. Processing of c Interrupt request c (level 3) Interrupt request d (level 2) Although the priority of interrupt request d is higher than that of c, d is held pending because interrupts are disabled. Processing of d Processing of e EI Interrupt request e (level 2) Interrupt request f (level 3) Interrupt request f is held pending even if interrupts are enabled because its priority is lower than that of e. Processing of f Processing of g EI Interrupt request g (level 1) Interrupt request h (level 1) Interrupt request h is held pending even if interrupts are enabled because its priority is the same as that of g. Processing of h Figure 5-7 Caution 234 Example of processing in which another interrupt request is issued while an interrupt is being processed (1/2) The values of the EIPC and EIPSW registers must be saved before executing multiple interrupts. When returning from multiple interrupt servicing, restore the values of EIPC and EIPSW after executing the DI instruction. User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Note Chapter 5 1. <a> to <u> in the figure are the temporary names of interrupt requests shown for the sake of explanation. 2. The default priority in the figure indicates the relative priority between two interrupt requests. Main routine Processing of i EI Interrupt request i (level 2) Processing of k EI Interrupt request j (level 3) Interrupt request k (level 1) Interrupt request j is held pending because its priority is lower than that of i. k that occurs after j is acknowledged because it has the higher priority. Processing of j Processing of l Interrupt request l (level 2) Interrupt requests m and n are held pending because processing of l is performed in the interrupt disabled status. Interrupt request m (level 3) Interrupt request n (level 1) Processing of n Pending interrupt requests are acknowledged after processing of interrupt request l. At this time, interrupt requests n is acknowledged first even though m has occurred first because the priority of n is higher than that of m. Processing of m Interrupt request o (level 3) Interrupt request p (level 2) Processing of o Processing of p EI Processing of q EI Processing of r EI Interrupt request q Interrupt (level 1) request r (level 0) If levels 3 to 0 are acknowledged Processing of s Interrupt request s (level 1) Interrupt request t (level 2) Interrupt request u (level 2) Note 1 Note 2 Pending interrupt requests t and u are acknowledged after processing of s. Because the priorities of t and u are the same, u is acknowledged first because it has the higher default priority, regardless of the order in which the interrupt requests have been generated. Processing of u Processing of t Figure 5-8 Example of processing in which another interrupt request is issued while an interrupt is being processed (2/2) User's Manual U18743EE1V2UM00 235 Chapter 5 Interrupt Controller (INTC) Caution Note The values of the EIPC and EIPSW registers must be saved before executing multiple interrupts. When returning from multiple interrupt servicing, restore the values of EIPC and EIPSW after executing the DI instruction. 1. Lower default priority 2. Higher default priority Main routine EI Interrupt request a (level 2) Interrupt request b (level 1) Interrupt request c (level 1) Default priority a>b>c NMI request Processing of interrupt request b Processing of interrupt request c . . Interrupt request b and c are acknowledged first according to their priorities. Because the priorities of b and c are the same, b is acknowledged first according to the default priority. Processing of interrupt request a Figure 5-9 236 Example of processing interrupt requests simultaneously generated Caution The values of the EIPC and EIPSW registers must be saved before executing multiple interrupts. When returning from multiple interrupt servicing, restore the values of EIPC and EIPSW after executing the DI instruction. Note <a> to <c> in the figure are the temporary names of interrupt requests shown for the sake of explanation. User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 5.3.4 xxICn - Maskable interrupt control registers An interrupt control register is assigned to each interrupt request (maskable interrupt) and sets the control conditions for each maskable interrupt request. Access Address Initial Value This register can be read/written in 1-bit or 8-bit units. FFFF F110H to FFFF F194H 47H. The register is initialized by any reset xxICn Bit position 7 6 5 4 3 2 1 0 xxIFn xxMKn 0 0 0 xxPR2 xxPR1 xxPR0 Bit name 7 xxIFn 6 xxMKn Function This is an interrupt request flag. 0: Interrupt request not issued 1: Interrupt request issued The flag xxIFn is reset automatically by the hardware if an interrupt request is acknowledged. This is an interrupt mask flag. 0: Enables interrupt processing 1: Disables interrupt processing (pending) 8 levels of priority order are specified for each interrupt. 2 to 0 xxPR2 to xxPR0 Note xxPR2 xxPR1 xxPR0 Interrupt priority specification bit 0 0 0 Specifies level 0 (highest) 0 0 1 Specifies level 1 0 1 0 Specifies level 2 0 1 1 Specifies level 3 1 0 0 Specifies level 4 1 0 1 Specifies level 5 1 1 0 Specifies level 6 1 1 1 Specifies level 7 (lowest) xx: identification name of each peripheral unit (LVIL, LVIH, P, TAA0OV-TAA4OV, TAA0CC-TAA4CC, TM0EQ, CB0R-CB1R, CB0T-CB1T, UD0S-UD2S, UD0RUD2R, UD0T-UD2T, IIC0, AD, C0ERR, C0WUP, C0REC, C0TRX, KR, WTI, WT, FL) The address and the availability of each interrupt control register for each device is shown in the following table. Note The symbols used in the table mean: : register available for the device -: register not available for the device User's Manual U18743EE1V2UM00 237 Chapter 5 238 Interrupt Controller (INTC) Address Register V850ES/FE3-L/ V850ES/FF3-L V850ES/FG3-L FFFFF110H LVILIC FFFFF112H LVIHIC FFFFF114H PIC0 FFFFF116H PIC1 FFFFF118H PIC2 FFFFF11AH PIC3 FFFFF11CH PIC4 FFFFF11EH PIC5 FFFFF120H PIC6 FFFFF122H PIC7 FFFFF12EH TAA0OVIC FFFFF130H TAA0CCIC0 FFFFF132H TAA0CCIC1 FFFFF134H TAA1OVIC FFFFF136H TAA1CCIC0 FFFFF138H TAA1CCIC1 FFFFF13AH TAA2OVIC FFFFF13CH TAA2CCIC0 FFFFF13EH TAA2CCIC1 FFFFF140H TAA3OVIC FFFFF142H TAA3CCIC0 FFFFF144H TAA3CCIC1 FFFFF146H TAA4OVIC FFFFF148H TAA4CCIC0 FFFFF14AH TAA4CCIC1 FFFFF14CH TM0EQIC0 FFFFF14EH CB0RIC FFFFF150H CB0TIC FFFFF152H CB1RIC FFFFF154H CB1TIC FFFFF156H UD0SIC FFFFF158H UD0RIC FFFFF15AH UD0TIC FFFFF15CH UD1SIC FFFFF15EH UD1RIC FFFFF160H UD1TIC FFFFF162H IIC0IC FFFFF164H ADIC FFFFF166H C0ERRIC FFFFF168H C0WUPIC FFFFF16AH C0RECIC FFFFF16CH C0TRXIC User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 Address Register V850ES/FE3-L/ V850ES/FF3-L V850ES/FG3-L FFFFF176H KRIC FFFFF178H WTIIC FFFFF17AH WTIC FFFFF17EH FLIC - - FFFFF180H PIC8 - FFFFF182H PIC9 - FFFFF184H PIC10 - FFFFF190H UD2SIC - FFFFF192H UD2RIC - FFFFF194H UD2TIC - User's Manual U18743EE1V2UM00 239 Chapter 5 Interrupt Controller (INTC) 5.3.5 IMRm - Interrupt mask registers These registers set the interrupt mask state for the maskable interrupts. The xxMKn bit of the IMRm registers is equivalent to the xxMKn bit of the xxICn register. * 16 bit IMRm registers are accessible through - 16 bit IMRm via the given <Address> and can be read/written in 16-bit units - 8 bit IMRmL = IMRm[7:0] registers via the given <Address> and can be read/written in 8- and 1-bit units - 8 bit IMRmH = IMRm[15:8] registers via <Address> + 1 and can be read/ written in 8- and 1-bit units * 8 bit IMRm registers are accessible through - 8 bit IMRm or IMRmL registers via the given <Address> and can be read/written in 8- and 1-bit units Caution 1. Mask bits without function, indicated with "1", must not be altered. Make sure to set them "1" when writing to the register. 2. The device file defines the xxMKn bit of the xxICn register as a reserved word. If a bit is manipulated using the name of xxMKn, the contents of the xxICn register, instead of the IMRm register, are rewritten (as a result, the contents of the IMRm register are also rewritten). Bit position Bit name 15 to 0 xxMKn Function Interrupt mask flag. 0: Interrupt servicing enabled 1: Interrupt servicing disabled (pending) xx: identification name of each peripheral unit (see the note in "xxICn Maskable interrupt control registers" on page 237 (1) IMR0 IMR0 - Interrupt mask register 0 15 14 13 12 11 10 9 8 Address Initial value TAA0OVMK 1 1 1 1 1 PMK7 PMK6 FFFFF100H FFFFH 7 6 5 4 3 2 1 0 PMK5 PMK4 PMK3 PMK2 PMK1 PMK0 LVIHMK LVILMK 10 9 8 Address Initial value (2) 15 IMR1 CB0RMK 7 IMR1 - Interrupt mask register 1 14 13 12 11 TM0EQMK0 TAA4CCMK1 TAA4CCMK0 TAA4OVMK TAA3CCMK1 TAA3CCMK0 TAA3OVMK FFFFF102H 6 5 4 3 2 1 0 TAA2CCMK1 TAA2CCMK0 TAA2OVMK TAA1CCMK1 TAA1CCMK0 TAA1OVMK TAA0CCMK1 TAA0CCMK0 240 User's Manual U18743EE1V2UM00 FFFFH Interrupt Controller (INTC) (3) IMR2 Chapter 5 IMR2 - Interrupt mask register 2 15 14 13 12 11 10 9 8 Address Initial value 0 C0TRXMK C0RECMK C0WUPMK C0ERRMK ADMK IIC0MK UD1TMK FFFFF104H FFFFH 7 6 5 4 3 2 1 0 UD1RMK UD1SMK UD0TMK UD0RMK UD0SMK CB1TMK CB1RMK CB0TMK (4) IMR3 - Interrupt mask register 3 * V850ES/FE3-L * V850ES/FF3-L IMR3 15 14 13 12 11 10 9 8 Address Initial value 1 1 1 1 1 1 1 1 FFFFF106H FFFFH 7 6 5 4 3 2 1 0 FLMK 1 WTMK WTIMK KRMK 1 1 1 * V850ES/FG3-L IMR3 15 14 13 12 11 10 9 8 Address Initial value 1 1 1 1 1 PMK10 PMK9 PMK8 FFFFF106H FFFFH 7 6 5 4 3 2 1 0 FLMK 1 WTMK WTIMK KRMK 1 1 1 (5) MR4 - Interrupt mask register 4 * V850ES/FG3-L IMR4 15 14 13 12 11 10 9 8 Address Initial value 1 1 1 1 1 1 1 1 FFFFF108H FFFFH 7 6 5 4 3 2 1 0 1 1 1 1 1 UD2TMK UD2RMK UD2SMK User's Manual U18743EE1V2UM00 241 Chapter 5 Interrupt Controller (INTC) 5.3.6 ISPR - In-service priority register This register holds the priority level of the maskable interrupt currently acknowledged. When an interrupt request is acknowledged, the bit of this register corresponding to the priority level of that interrupt request is set to 1 and remains set while the interrupt is serviced. When the RETI instruction is executed, the bit corresponding to the interrupt request having the highest priority is automatically reset to 0 by hardware. However, it is not reset to 0 when execution is returned from non-maskable interrupt servicing or exception processing. This register is read-only in 8-bit or 1-bit units. ISPR 7 6 5 4 3 2 1 0 Address Initial value ISPR7 ISPR6 ISPR5 ISPR4 ISPR3 ISPR2 ISPR1 ISPR0 FFFFF1FAH 00H Bit position Bit name 7 to 0 ISPR7 to ISPR0 Note Caution 242 Function Indicates priority of interrupt currently acknowledged 0: Interrupt request with priority n not acknowledged 1: Interrupt request with priority n acknowledged n = 0 to 7 (priority level) If an interrupt is acknowledged while the ISPR register is being read in the interrupt enabled (EI) state, the value of the ISPR register after the bits of the register have been set by acknowledging the interrupt may be read. To accurately read the value of the ISPR register before an interrupt is acknowledged, read the register while interrupts are disabled (DI). User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 5.3.7 Maskable interrupt status flag (ID) The ID flag is bit 5 of the PSW and this controls the maskable interrupt's operating state, and stores control information regarding enabling or disabling of interrupt requests. 31 PSW 0 8 7 6 5 4 3 2 1 0 Initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NP EP ID SAT CY OV S Z 00000020H Bit position 5 Bit name Function ID Indicates whether maskable interrupt processing is enabled or disabled. 0: Maskable interrupt request acknowledgement enabled 1: Maskable interrupt request acknowledgement disabled (pending) This bit is set to 1 by the DI instruction and reset to 0 by the EI instruction. Its value is also modified by the RETI instruction or LDSR instruction when referencing to PSW. Non-maskable interrupt requests and exceptions are acknowledged regardless of this flag. when a maskable interrupt is acknowledged, the ID flag is automatically set to 1 by hardware. The interrupt request generated during the acknowledgement disabled period (ID = 1) is acknowledged when the PIFn bit of PICn register is set to 1, and the ID flag is reset to 0. 5.3.8 External maskable interrupts This microcontroller provides maskable external interrupts INTPn with the following features: * Analog input filter (refer to "Analog filtered inputs" on page 126) * Digital input filter for INTP3 (refer to "Digitally filtered inputs" on page 127) * Interrupt detection selectable for each interrupt input: - Rising edge - Falling edge - Both edges: rising and falling edge For configuration of the external interrupt events refer to "External Interrupts Edge Detection Configuration" on page 244. User's Manual U18743EE1V2UM00 243 Chapter 5 Interrupt Controller (INTC) 5.4 External Interrupts Edge Detection Configuration The microcontroller provides the maskable external interrupts INTPn and one non-maskable interrupt (NMI). INTPn and NMI can be configured to generate interrupts upon rising, falling or both edges. Two register sets are provided to specify edges and levels for each external interrupt. INTRm The INTRm registers specify the rising edge for edge detection of corresponding external interrupt signals. This register can be read/written in 8-bit and 1-bit units. 16-bit registers can also be read/written in 16-bit units. Bit position Function Specifies the edge detection for external interrupt signals INTRm[15:0] 0: no detection at rising edge 1: detection at rising edge 15 to 0 INTFm Bit name The INTFm registers specify the falling edge for edge detection of corresponding external interrupt signals. This register can be read/written in 8-bit and 1-bit units. 16-bit registers can also be read/written in 16-bit units. Bit position 15 to 0 Caution (1) INTR0 INTF0 244 Bit name Function Specifies the edge detection for external interrupt signals INTFm[15:0] 0: no detection at falling edge 1: detection at falling edge When the function of the dedicated pin is changed from the external interrupt function (alternate function) to the port function, an edge may be detected. Therefore, first clear INTRm.INTRmk / INTFm.INTFmk (k = 0 to 15) to 0, and then set the port mode. INTR0/INTF0 - External interrupt edge specification register 0 7 6 5 4 3 2 1 0 0 INTR06 INTR05 INTR04 INTR03 INTR02 0 0 INTP3 INTP2 INTP1 INTP0 NMI 7 6 5 4 3 2 1 0 0 INTF06 INTF05 INTF04 INTF03 INTF02 0 0 INTP3 INTP2 INTP1 INTP0 NMI User's Manual U18743EE1V2UM00 Address Initial value FFFF FC20H 00H Address Initial value FFFF FC00H 00H Interrupt Controller (INTC) (2) Chapter 5 INTR1/INTF1 - External interrupt edge specification register 1 * V850ES/FG3-L INTR1 INTF1 7 6 5 4 3 2 1 0 0 0 0 0 0 0 INTR11 INTR10 INTP10 INTP9 7 6 5 4 3 2 1 0 0 0 0 0 0 0 INTF11 INTF10 INTP10 INTP9 (3) Address Initial value FFFF FC22H 00H Address Initial value FFFF FC02H 00H INTR3/INTF3 - External interrupt edge specification register 3 * V850ES/FE3-L * V850ES/FF3-L INTR3L 7 6 5 4 3 2 1 0 0 0 0 0 0 0 INTR31 0 Address Initial value FFFF FC26H 0000H INTP7 INTF3L 7 6 5 4 3 2 1 0 0 0 0 0 0 0 INTF31 0 Address Initial value FFFF FC06H 0000H INTP7 * V850ES/FG3-L INTR3 a 15 14 13 12 11 10 9 8 0 0 0 0 0 0 INTR39 0 Address Initial value FFFF FC26H 0000H INTP8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 INTR31 0 INTP7 a) Both bytes of this 16-bit register can also be accessed bytewise with - INTR3L = INTR3[7:0] under the address FFFF FC26H - INTR3H = INTR3[15:8] under the address FFFF FC27H INTF3 a 15 14 13 12 11 10 9 8 0 0 0 0 0 0 INTF39 0 Address Initial value FFFF FC06H 0000H INTP8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 INTF31 0 INTP7 User's Manual U18743EE1V2UM00 245 Chapter 5 a) 246 Interrupt Controller (INTC) Both bytes of this 16-bit register can also be accessed bytewise with - INTF3L = INTF3[7:0] under the address FFFF FC06H - INTF3H = INTF3[15:8] under the address FFFF FC07H User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 5.5 Software Exception A software exception is generated when the CPU executes the TRAP instruction, and can be always acknowledged. 5.5.1 Operation If a software exception occurs, the CPU performs the following processing, and transfers control to the handler routine: 1. Saves the restored PC to EIPC. 2. Saves the current PSW to EIPSW. 3. Writes an exception code to the lower 16 bits (EICC) of ECR (interrupt source). 4. Sets the EP and ID bits of the PSW. 5. Sets the handler address (00000040H or 00000050H) corresponding to the software exception to the PC, and transfers control. Figure 5-10 illustrates the processing of a software exception. TRAP instructionNote CPU processing EIPC EIPSW ECR.EICC PSW.EP PSW.ID PC restored PC PSW exception code 1 1 handler address Exception processing Figure 5-10 Note Software exception processing TRAP Instruction Format: TRAP vector (the vector is a value from 0 to 1FH.) The handler address is determined by the TRAP instruction's operand (vector). If the vector is 0 to 0FH, it becomes 00000040H, and if the vector is 10H to 1FH, it becomes 00000050H. User's Manual U18743EE1V2UM00 247 Chapter 5 Interrupt Controller (INTC) 5.5.2 Restore Recovery from software exception processing is carried out by the RETI instruction. By executing the RETI instruction, the CPU carries out the following processing and shifts control to the restored PC's address. 1. Loads the restored PC and PSW from EIPC and EIPSW because the EP bit of the PSW is 1. 2. Transfers control to the address of the restored PC and PSW. Figure 5-11 illustrates the processing of the RETI instruction. RETI instruction 1 PSW.EP 0 PSW.NP 1 0 PC PSW EIPC EIPSW PC PSW FEPC FEPSW Original processing restored Figure 5-11 Caution Note 248 RETI instruction processing When the PSW.EP bit and the PSW.NP bit are changed by the LDSR instruction during the software exception processing, in order to restore the PC and PSW correctly during recovery by the RETI instruction, it is necessary to set PSW.EP back to 1 using the LDSR instruction immediately before the RETI instruction. The solid lines show the CPU processing flow. User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 5.5.3 Exception status flag (EP) The EP flag is bit 6 of PSW, and is a status flag used to indicate that exception processing is in progress. It is set when an exception occurs. 31 PSW 0 8 7 6 5 4 3 2 1 0 Initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NP EP ID SAT CY OV S Z 00000020H Bit position Bit name 6 EP Function Shows that exception processing is in progress. 0: Exception processing not in progress. 1: Exception processing in progress. 5.6 Exception Trap An exception trap is an interrupt that is requested when an illegal execution of an instruction takes place. For this microcontroller, an illegal opcode exception (ILGOP: Illegal Opcode Trap) is considered as an exception trap. 5.6.1 Illegal opcode definition The illegal instruction has an opcode (bits 10 to 5) of 111111B, a sub-opcode (bits 23 to 26) of 0111B to 1111B, and a sub-opcode (bit 16) of 0B. An exception trap is generated when an instruction applicable to this illegal instruction is executed. 1 5 x x x x 1 1 1 0 x 1 1 1 1 1 5 4 1 x x x x 0 3 1 x x 2 7 x x x x 2 6 0 (1) 1 1 1 1 1 to 1 Note 2 3 1 2 2 x 1 6 x x x x x 0 x: Arbitrary Operation If an exception trap occurs, the CPU performs the following processing, and transfers control to the handler routine: 1. 2. 3. 4. Saves the restored PC to DBPC. Saves the current PSW to DBPSW. Sets the NP, EP, and ID bits of the PSW. Sets the handler address (00000060H) corresponding to the exception trap to the PC, and transfers control. Figure 5-12 illustrates the processing of the exception trap. User's Manual U18743EE1V2UM00 249 Chapter 5 Interrupt Controller (INTC) Exception trap (ILGOP) occurs CPU processing DBPC DBPSW PSW.NP PSW.EP PSW.ID PC restored PC PSW 1 1 1 00000060H Exception processing Figure 5-12 (2) Exception trap processing Restore Recovery from an exception trap is carried out by the DBRET instruction. By executing the DBRET instruction, the CPU carries out the following processing and controls the address of the restored PC. 1. Loads the restored PC and PSW from DBPC and DBPSW. 2. Transfers control to the address indicated by the restored PC and PSW. Figure 5-13 illustrates the restore processing from an exception trap. DBRET instruction PC PSW DBPC DBPSW Jump to address of restored PC Figure 5-13 Note 250 Restore processing from exception trap The DBPC and DBPSW registers can be accessed only when the DBTRAP instruction is executed. User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 5.6.2 Debug trap The debug trap is an exception that can be acknowledged every time and is generated by execution of the DBTRAP instruction. When the debug trap is generated, the CPU performs the following processing. (1) Operation When the debug trap is generated, the CPU performs the following processing, transfers control to the debug monitor routine, and shifts to debug mode. 1. 2. 3. 4. Saves the restored PC to DBPC. Saves the current PSW to DBPSW. Sets the NP, EP and ID bits of the PSW. Sets the handler address (00000060H) corresponding to the debug trap to the PC and transfers control. Figure 5-14 illustrates the processing of the debug trap. DBTRAP instruction CPU processing DBPC DBPSW PSW.NP PSW.EP PSW.ID PC restored PC PSW 1 1 1 00000060H Exception processing Figure 5-14 (2) Debug trap processing Restore Recovery from a debug trap is carried out by the DBRET instruction. By executing the DBRET instruction, the CPU carries out the following processing and controls the address of the restored PC. 1. Loads the restored PC and PSW from DBPC and DBPSW. 2. Transfers control to the address indicated by the restored PC and PSW. User's Manual U18743EE1V2UM00 251 Chapter 5 Interrupt Controller (INTC) Figure 5-15 illustrates the restore processing from a debug trap. DBRET instruction PC PSW DBPC DBPSW Jump to address of restored PC Figure 5-15 Restore processing from debug trap 5.7 Multiple Interrupt Processing Control Multiple interrupt processing control is a process by which an interrupt request that is currently being processed can be interrupted during processing if there is an interrupt request with a higher priority level, and the higher priority interrupt request is received and processed first. If there is an interrupt request with a lower priority level than the interrupt request currently being processed, that interrupt request is held pending. Maskable interrupt multiple processing control is executed when an interrupt has an enable status (ID = 0). Thus, if multiple interrupts are executed, it is necessary to have an interrupt enable status (ID = 0) even for an interrupt processing routine. If a maskable interrupt enable or a software exception is generated in a maskable interrupt or software exception service program, it is necessary to save EIPC and EIPSW. This is accomplished by the following procedure. 252 User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) (1) Chapter 5 Acknowledgment of maskable interrupts in service program Service program of maskable interrupt or exception ... ... *EIPC saved to memory or register *EIPSW saved to memory or register *EI instruction (interrupt acknowledgment enabled) ... ... Maskable interrupt acknowledgment ... *DI instruction (interrupt acknowledgment disabled) *Saved value restored to EIPSW *Saved value restored to EIPC *RETI instruction (2) Generation of exception in service program Service program of maskable interrupt or exception ... ... *EIPC saved to memory or register *EIPSW saved to memory or register ... *TRAP instruction Exception such as TRAP instruction acknowledged. ... *Saved value restored to EIPSW *Saved value restored to EIPC *RETI instruction The priority order for multiple interrupt processing control has 8 levels, from 0 to 7 for each maskable interrupt request (0 is the highest priority), but it can be set as desired via software. Setting of the priority order level is done using the PPRn0 to PPRn2 bits of the interrupt control request register (PlCn), which is provided for each maskable interrupt request. After system reset, an interrupt request is masked by the PMKn bit and the priority order is set to level 7 by the PPRn0 to PPRn2 bits. The priority order of maskable interrupts is as follows. (High) Level 0 > Level 1 > Level 2 > Level 3 > Level 4 > Level 5 > Level 6 > Level 7 (Low) User's Manual U18743EE1V2UM00 253 Chapter 5 Interrupt Controller (INTC) Interrupt processing that has been suspended as a result of multiple processing control is resumed after the processing of the higher priority interrupt has been completed and the RETI instruction has been executed. A pending interrupt request is acknowledged after the current interrupt processing has been completed and the RETI instruction has been executed. Caution In a non-maskable interrupt processing routine (time until the RETI instruction is executed), maskable interrupts are suspended and not acknowledged. 5.8 Interrupt Response Time The following table describes the interrupt response time (from interrupt generation to start of interrupt processing). Except in the following cases, the interrupt response time is a minimum of 5 clocks. * During software or hardware STOP mode * When there are two or more successive interrupt request non-sampling instructions (see "Periods in which interrupts are not acknowledged" on page 255). * When the interrupt control register is accessed 5 system clocks VBCLK (Input) Interrupt request Instruction 1 Instruction 2 IF ID IFX IDX Interrupt acknowledgement operation Instruction (first instruction of interrupt service routine) Figure 5-16 254 EX MEM WB INT1 INT2 INT3 INT4 IF ID EX Pipeline operation at interrupt request acknowledgment (outline) Note INT1 to INT4: Interrupt acknowledgement processing IFx: Invalid instruction fetch IDx: Invalid instruction decode Note If the same interrupt occurs during the interrupt acknowledge time of 5 cycles, this new interrupt will discarded. The next interrupt of the same source will only be registered after these 5 cycles. User's Manual U18743EE1V2UM00 Interrupt Controller (INTC) Chapter 5 Interrupt response time (internal system clocks) Minimum Internal interrupt External interrupt 4 4 + analog delay time 6 (in case of latency = 2) 6 + analog delay time (in case of latency = 2) Condition The following cases are exceptions: * In IDLE/software STOP mode Maximum 7 (in case of latency = 3) 7 + analog delay time (in case of latency = 3) * External bit access * Two or more interrupt request nonsample instructions are executed * Access to interrupt control register 5.9 Periods in which interrupts are not acknowledged An interrupt is acknowledged while an instruction is being executed. However, no interrupt will be acknowledged between an interrupt non-sample instruction and the next instruction. The interrupt request non-sampling instructions are as follows: * EI instruction * DI instruction * LDSR reg2, 0x5 instruction (for PSW) * The store instruction for the interrupt control register (PlCn), in-service priority register (ISPR), and command register (PRCMD).* The store instruction for the following registers and SET1, NOT1, CLR1 instruction. * Interrupt registers: Interrupt control register (xxICn), interrupt mask registers 0 to 7 (IMR0 to IMR7) * In-service priority register (ISPR) * Command register (PRCMD) * Power save control register (PSC) * On-chip debug mode register (OCDM) Peripheral emulation register 1 (PEMU1) User's Manual U18743EE1V2UM00 255 Chapter 5 256 Interrupt Controller (INTC) User's Manual U18743EE1V2UM00 Chapter 6 Key Interrupt Function 6.1 Function A key interrupt request signal (INTKR) can be generated by inputting a falling edge to the eight key input pins (KR0 to KR7) by setting the key return mode register (KRM). Table 6-1 Assignment of Key Return Detection Pins Flag Pin Description KRM0 Controls KR0 signal in 1-bit units KRM1 Controls KR1 signal in 1-bit units KRM2 Controls KR2 signal in 1-bit units KRM3 Controls KR3 signal in 1-bit units KRM4 Controls KR4 signal in 1-bit units KRM5 Controls KR5 signal in 1-bit units KRM6 Controls KR6 signal in 1-bit units KRM7 Controls KR7 signal in 1-bit units KR7 KR6 KR5 KR4 INTKR KR3 KR2 KR1 KR0 KRM7 KRM6 KRM5 KRM4 KRM3 KRM2 KRM1 KRM0 Key return mode register (KRM) Figure 6-1 Key Return Block Diagram User's Manual U18743EE1V2UM00 257 Chapter 6 Key Interrupt Function 6.2 Control Register (1) KRM - Key return mode register The KRM register controls the KRM0 to KRM7 bits using the KR0 to KR7 signals. Access Address Initial Value Table 6-2 This register can be read/written in 8-bit or 1-bit units. FFFF F300H. 00H. This register is cleared by any reset. 7 6 5 4 3 2 1 0 KRM7 KRM6 KRM5 KRM4 KRM3 KRM2 KRM1 KRM0 R/W R/W R/W R/W R/W R/W R/W R/W LOCKR register contents Bit name KRMn Caution Note Function Control of key return mode: 0: Does not detect key return signal. 1: Detects key return signal. If the KRM register is changed, the interrupt request signal INTKR may be generated. To prevent this, change the KRM register after disabling interrupts (DI), and then enable interrupts (EI) after clearing the interrupt request flag (KRIC.KRIF = 0). For the alternate-function pin settings, see "Pin Functions" on page 31. 6.3 Cautions 1. If a low level is input to any of the KR0 to KR7 pins, the INTKR signal is not generated even if the falling edge of another pin is input. 2. If the KRM register is changed, an interrupt request signal (INTKR) may be generated. To prevent this, change the KRM register after disabling interrupts (DI), and then enable interrupts (EI) after clearing the interrupt request flag (KRIC.KRIF bit) to 0. 3. To use the Key Interrupt Function, be sure to set the port pin to the key return pin and then enable the operation with the KRM register. To switch from the key return pin to the port pin, disable the operation with the KRM register and then set the port pin. 4. Before writing a new value to the KRM register write a value of 0x00 to the KRM register first. 258 User's Manual U18743EE1V2UM00 Chapter 7 Flash Memory The following V850ES/Fx3-L devices are equipped with internal flash memory : Product Device V850ES/FE3-L PD70F3610 64 KB PD70F3611 96 KB PD70F3612 128 KB PD70F3613 192 KB PD70F3614 256 KB PD70F3615 64 KB PD70F3616 96 KB PD70F3617 128 KB PD70F3618 192 KB PD70F3619 256 KB PD70F3620 128 KB PD70F3621 192 KB PD70F3622 256 KB V850ES/FF3-L V850ES/FG3-L Code flash size The code flash memory is attached to the dedicated fetch bus interface of the V850 CPU core. It is used for non-volatile storage of program code and constant data. Flash memory is commonly used in the following development environments and applications: * For altering software after solder-mounting of the microcontroller on the target system. * For differentiating software in small-scale production of various models. * For data adjustment when starting mass production. * For facilitating inventory management. * For updating software after shipment. The flash memory can be written in different ways: * by a flash programmer equipped with a suitable adapter (off-board write) * mounted on the target board by connecting a dedicated flash programmer to the target system (on-board write) * by the microcontroller's application software (self-programming) Additionally a flash memory address space is provided to hold various configuration settings, called option bytes. Via the option bytes start-up configurations can be set for e.g. the Clock Generator and the Watchdog Timer. The option bytes can be written by use of an external flash programmer and in self-programming mode. User's Manual U18743EE1V2UM00 259 Chapter 7 Flash Memory 7.1 Code Flash Memory Overview 7.1.1 Code flash memory features * 4-byte/1 CPU clock access during instruction fetch * All-blocks or multiple blocks batch erase or single block erase * Erase/write with single power supply * Communication with dedicated flash programmer via various serial interfaces * On-board and off-board programming * Flash memory programming by self-programming 260 User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 7.1.2 Code flash memory mapping The microcontroller's internal code flash memory area is divided into blocks of 2 KB respectively 4 KB blocks and can be programmed/erased in block units. All or some of the blocks can also be erased at once. Following figures list the block structures and address assignments for all V850ES/Fx3-L devices with code flash memory. Additional information comprise: * Boot swap cluster size Configurable size of boot cluster for secure self-programming, refer to "Secure self-programming (boot cluster swapping)" on page 279. * Interleave Interleave configuration of the flash memory blocks. * CPU branch latency Number of additional CPU clock cycles during instruction fetches of nonlinear code. The CPU branch latency may be configurable by the LATENCY control bit of the option byte at address 0000 007BH. Block 127 (2 KB) 0003 FFFFH 0003 F800H 0002 FFFFH Block 95(2 KB) 0002 0800H ... 0001 FFFFH 0001 F800H ... 0001 7FFFH Block 47(2 KB) Address Block 63(2 KB) ... 0001 7800H ... ... 0000 FFFFH Block 31 (2 KB) ... 0000 F800H ... 0000 07FFH Block 0 (2 KB) Block 0 (2 KB) Block 0 (2 KB) Block 0 (2 KB) Block 0 (2 KB) 64 KB 96 KB 128 192 KB 8/16/32/64 KB PD70F3613 PD70F3618 PD70F3621 256 KB 0000 0000H 8/16/32 KB PD70F3610 PD70F3611 PD70F3615 PD70F3616 Figure 7-1 PD70F3612 PD70F3617 PD70F3620 Code flash size Boot swap cluster sizes PD70F3614 PD70F3619 PD70F3622 Products Code flash memory configuration for V850ES/Fx3-L devices. User's Manual U18743EE1V2UM00 261 Chapter 7 Flash Memory 7.1.3 Code flash memory functional outline Serial programming The internal flash memory of the microcontroller can be rewritten by using the rewrite function of a dedicated flash programmer, regardless of whether the microcontroller has already been mounted on the target system or the device is not mounted (off-board/on-board programming). Since there is no functional difference between on-board and off-board programming by an external flash programmer, both will be gathered as "serial programming" - in contrast "to self-programming". Self-programming The self-programming facility, which facilitates rewriting of the flash memory by the user program, is ideal for program updates after production and shipment, since no additional programming equipment is required. During selfprogramming some software services as well as interrupt serving can still be in operation, e.g to sustain communication with other devices. While the self-programming mode can be initiated from the normal operation mode the external flash programmer mode is entered immediately after release of a system reset. Refer to "Flash memory programming control" on page 271 for details on how to enter normal operation or serial flash programming mode. Extra area The flash memory contains an extra area, used to store the settings of security and protection functions, the variable reset vector and other flash relevant information. The extra area is not mapped into the CPU's address space, thus is not directly accessible by the user's program. The extra area's settings can only be read and modified by an external programmer or by self-programming. Boot swap A boot swap function makes safe re-programming of the flash memory possible and is used to maintain an operable software version, even if reprogramming fails for any reason, e.g. in a power fail situation. For further information concerning boot swapping refer to "Secure selfprogramming (boot cluster swapping)" on page 279. Protection A set of protection flags can be specified during flash memory programming to prohibit access the flash memory in different ways, implying read-out, rewrite and erase protections. By these means the code flash memory can be protected against read-out and rewrite of the flash memory content by unauthorized persons. For further information concerning data protection refer to "Data Protection and Security" on page 289. Variable reset vector The variable reset vector function allows flexible assignment of the application program start by redefinition of the reset vector. For further information concerning the variable reset vector refer to "Variable Reset Vector" on page 284. 262 User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 Table 7-1 Flash memory write methods Environment Interface Outline Operation Mode Serial programming Serial I/F (UART, CSI) Flash memory programming is done by an external Flash memory flash programmer. programming The device may be mounted on the target system (on- mode board) or unmounted (off-board) by using a suitable programming adapter board. In either case the communication between the device and the flash progammer is using a serial interface. For details refer to "Flash Programming with Flash Programmer" on page 266. Selfprogramming Self-programming library Flash memory can be rewritten by executing a user program that has been written to the flash memory in advance by means of off-board/on-board programming. The self-programming library provides all necessary functions to be called by the application software. For details refer to "Code Flash Self-Programming" on page 277. Normal operation mode Table 7-2 on page 264 summarizes the functions used to modify flash memory content. User's Manual U18743EE1V2UM00 263 Chapter 7 Flash Memory Table 7-2 Function Basic functions for flash memory modifications Functional outline Support (: Supported, x: Not supported) Serial programming Self-programming Block erasure The contents of specified memory blocks are erased. Multiple block erasure The contents of the specified successive multiple blocks are erased. Chip erasure The contents of the entire memory area is erased all at once. The extra area - except the boot block cluster protection flag - is also erased. xa Write Writing to specified addresses, and a verify check to see if write level is secured are performed. Verify Data read from the flash memory is compared with data transferred from the flash programmer. xb Checksum Microcontroller internally calculated checksum over the entire flash memory content is compared with the checksum calculated by the serial programmer x Blank check The erasure status of the entire memory is checked. Protection settings Following functions can be prohibited: * chip erase * block erase * write * read * rewriting of the boot block cluster c a) b) c) In self-programming mode all blocks can be specified to be erased at once by block erasure. Note that the extra area is not erased in this case. Can be carried out by the user's program. Except protection against rewriting of the boot block cluster all other protections have no effect in self-programming mode. Protection settings can be activated in self-programming mode. Already activate protection settings can not be deactivated. The following table lists the available flash memory protection functions. For details refer to "Data Protection and Security" on page 289. Table 7-3 Function Protection functions Functional outline Applicable (: applies, x: doesn't apply) Serial programming Self-programming Chip erase command prohibit Erasure of the entire flash (including the extra areaa) or single blocks impossible. x Block erase command prohibit Erasure of single blocks impossible. x Program command prohibit Erasure and rewrite of single blocks impossible. x Read command prohibit Read-out of any flash content impossible. x Rewriting boot area prohibit Erasure (by block or chip erase) or writing of the boot block cluster impossible. 264 User's Manual U18743EE1V2UM00 Flash Memory a) Chapter 7 The boot block cluster protection flag is not erased. 7.1.4 Code flash memory erasure and rewrite Erasure According to its block structure the flash memory can be erased in two different modes. * All-blocks batch erasure (chip erase) All blocks are erased all together. * Block erasure Each 2 KB flash memory block can be erased separately. In self-programming mode any number of contiguous flash memory blocks can be erased all together. Rewrite In self- and serial programming mode it is possible to rewrite the flash memory in smaller units than one block. Once a complete block has been erased it can be rewritten in units of 8 bytes. Each unit can be rewritten only once after erasure of the complete block. User's Manual U18743EE1V2UM00 265 Chapter 7 Flash Memory 7.2 Flash Programming with Flash Programmer A dedicated flash programmer can be used for external writing of the flash memory. * On-board programming The contents of the flash memory can be rewritten with the microcontroller mounted on the target system. Mount a connector that connects the flash programmer on the target system. * Off-board programming The flash memory of the microcontroller can be written before the device is mounted on the target system, by using a dedicated programming adapter. 7.2.1 Programming environment The necessary environment to write a program to the flash memory of the microcontroller is shown below. FLMD0 (FLMD1Note) VDD USB XXXXXX XXXX Bxxxxx Cxxxxxx STATVE PG-FP4 (Flash Pro4v) XXXXX XXXX YYYY Axxxx XXX YYY RS-232-C VSS RESET Flash programmer Host machine UART/CSI N-Wire HS V850 microcontroller Note: FLMD1 connection may be replaced by a pull-down resistor on the board Figure 7-2 Environment to write program to flash memory A host machine is required for controlling the flash programmer. Following microcontroller serial interfaces can be used as the interface between the flash programmer and the microcontroller: * asynchroneous serial interface UART * clocked serial interface CSI * serial debug interface N-Wire If a CSI interface is used with handshake, the flash programmer's HS signal is connected to a certain V850 port, in the following generally named as HSPORT. The port used as HSPORT for this product is given in Table 7-6. Flash memory programming off-board requires a dedicated programming adapter. In this chapter the terms UART and CSI may be used generically for the dedicated interface types and channels the microcontroller provides. UART and CSI signal names are used accordingly. 266 User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 7.2.2 Communication mode The communication between the flash programmer and the microcontroller utilizes the asynchronous serial interface UART or optionally the synchronous serial interface CSI. For programming via the synchronous serial interface CSI without handshake and with handshake modes are supported. In the latter mode the port pin HSPORT is used for the programmer's handshake signal HS. (1) UART The external flash programmer offers various choices of available baud rates. FLMD0 (FLMD1Note) VDD VDD GND VSS XXXXXX XXXX Bxxxxx Cxxxxxx XXXXX STATVE XXX YYY XXXX YYYY Axxxx FLMD0 (FLMD1Note) PG-FP4 (Flash Pro4) RESET Flash programmer RESET RXD TXD TXD RXD V850 microcontroller Note: FLMD1 connection may be replaced by a pull-down resistor on the board Figure 7-3 Communication with flash programmer via UART (2) CSI without handshake The external flash programmer offers various choices of available clock rates. FLMD0 (FLMD1Note) XXXXXX VDD VDD GND VSS XXXX Cxxxxxx STATVE PG-FP4 (Flash Pro4) XXXXX XXX YYY XXXX YYYY Axxxx Bxxxxx FLMD0 (FLMD1Note) flash programmer RESET RESET SI SO SO SI SCK SCK V850 microcontroller Note: FLMD1 connection may be replaced by a pull-down resistor on the board Figure 7-4 Communication with flash programmer via CSI without handshake The flash programmer outputs a transfer clock and the microcontroller operates as a slave. User's Manual U18743EE1V2UM00 267 Chapter 7 Flash Memory (3) CSI with handshake (CSI + HS) The external flash programmer offers various choices of available clock rates. FLMD0 (FLMD1Note) VDD VDD GND VSS XXXXXX STATVE PG-FP4 (Flash Pro4) XXXXX XXXX Bxxxxx Cxxxxxx XXX YYY XXXX YYYY Axxxx FLMD0 (FLMD1Note) flash programmer RESET RESET SI SO SO SI SCK SCK V850 microcontroller HSPORT HS Note: FLMD1 connection may be replaced by a pull-down resistor on the board Figure 7-5 Communication with flash programmer via CSI with handshake The flash programmer outputs a transfer clock and the microcontroller operates as a slave. (4) N-Wire Serial clock DCK: Up to 1 MHz VDD GND VSS FLMD1 FLMD0 SI/RXD DDO XXXXXX XXXX Bxxxxx Cxxxxxx STATVE PG-FP4 (Flash Pro4) XXXXX XXX YYY XXXX YYYY Axxxx VDD SO/TXD flash programmer Figure 7-6 268 SCK DDI DCK RESET DRST FLMD0 DMS V850 microcontroller Communication with flash programmer via N-Wire User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 7.2.3 Pin connection with flash programmer PG-FP4 A connector must be mounted on the target system to connect the flash programmer for on-board writing. In addition, functions to switch between the normal operation mode and flash memory programming mode and to control the microcontroller's reset pin must be provided on the board. When the flash memory programming mode is set, all the pins not used for flash memory programming are in the same status as immediately after reset. If the PG-FP4 is used as the flash programmer, it generates the signals listed in Table 7-4 for the microcontroller. For details, refer to the PG-FP4 User's Manual (U15260E). Table 7-4 Signals generated by flash programmer PG-FP4 PG-FP4 Signal name I/O Controller Pin function Pin name Connection UART CSI CSI + HS FLMD0 Output Write enable/disable FLMD0 FLMD1 Output Write enable/disable FLMD1 x x x VDD I/O VDD voltage generation/ voltage monitor VDD GND - Ground VSS CLK Output Clock output to the controller X1 x x x RESET Output Reset signal RESET SI/RXD Input Receive signal SO/TXD SO/TXD Output Transmit signal SI/RXD SCK Output Transfer clock SCK x HS Input Handshake signal for CSI + HS communication HSPORT x x Note : x: N-Wire Must be connected. Does not have to be connected. VDD1 VSS1 User's Manual U18743EE1V2UM00 269 Chapter 7 Flash Memory Table 7-5 Wiring of V850ES/Fx3-L flash writing adapters for CSIB Flash programmer (FG-FP4) connection pin Name of FA board pin UARTA0 CSIB0 + HS CSIB0 N-Wire Pin name Pin name Pin name Pin name Receive signal SI TXDA0 SOB0 SO/TxD O Transmit signal SO RXDA0 SIB0 SCK O Transfer clock SCK Not needed SCKB0 CLK O Clock to V850 microcontroller X1 Leave open X2 Leave open Signal name SI/RxD I/O I Pin function RESET O Reset signal RESET RESET FLMD0 I Write voltage FLMD0 FLMD0 FLMD1 I Write voltage FLMD1 FLMD1 HS I Handshake signal for CSI + HS VDD - VDD voltage generation/ voltage monitor RESERVE/ HS Not needed PCM0 VDD Not needed Not needed VDD BVDD EVDD AVREF0 GND - Ground GND VSS BVSS EVSS AVSS Table 7-6 Port V850ES/FE3-L pin nr. V850ES/FF3-L pin nr. V850ES/FG3-L pin nr. TXDD0 P30 22 22 25 RXDD0 P31 23 23 26 SIB0 P40 19 19 22 SOB0 P41 20 20 23 SCKB0 P42 21 21 24 RESET - 9 14 14 FLMD0 - 3 8 8 FLMD1 PDL5 52 61 76 PCM0 PCM0 45 49 61 DRST P05 17 17 20 DDI P52 30 34 39 DDO P53 31 35 40 DCK P54 34 36 41 DMS P55 35 37 42 Pin name 270 V850ES/Fx3-L pin numbers for serial programming User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 7.2.4 Flash memory programming control The procedure to program the flash memory is illustrated below. Reset/FLMD0 pulse supply Note: Figure 7-7 A reset pulse is required to initiate the selection of the flash programming mode. Flash memory programming procedure User's Manual U18743EE1V2UM00 271 Chapter 7 Flash Memory (1) Operation mode control To rewrite the contents of the flash memory by using the flash programmer, set the microcontroller in the flash memory programming mode. To set this mode, set the FLMD0 and FLMD1 pins as shown in Table 7-7 on page 272 and release RESET. In the normal operation mode, VSS is input to the FLMD0 pin. A pull-down resistor at the FLMD0 pin ensures normal operation mode if no flash programmer is connected. In the flash memory programming mode, the VDD write voltage is supplied to the FLMD0 pin. Additionally the FLMD1 pin has to hold VSS level. Table 7-7 Operation mode setting Pins Operation mode FLMD0 FLMD1 VSS Don't care Normal operation mode VDD VSS Flash programming mode VDD Setting prohibited An example of connection of the FLMD0 and FLMD1 pins is shown below. FLMD1 can be connected to ground via a resistor. Alternatively the FLMD1 pin may also be connected directly to the FLMD1 signal of the flash programmer. PG-FP4 FLMD0 FLMD0 FLMD1 FLMD1 PG-FP4 Figure 7-8 V850 V850 FLMD0 FLMD0 FLMD1 FLMD1 Example of connection to flash programmer PG-FP4 Once started in normal operation mode (FLMD0 = 0), FLMD0 pin is used for enabling self-programming. Refer also to 7.3 on page 277. 272 User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 (2) Serial I/O signals Potential conflicts with on-board signal connections If other devices are connected to the serial interface pins in use for flash memory programming in on-board programming mode take care that the concerned signals do not conflict with the signals of the flash programmer and the microcontroller. Output pins of the other devices must be isolated or set in high impedance state. Ensure that the other devices do not malfunction because of flash programmer signals. V850 C output Flash programmer input Other device isolate or disable V850 C Flash programmer input input Other device isolate or disable V850 C input Flash programmer input Other device isolate or disable or Hi-Z Figure 7-9 RESET Potential conflicts with serial interfaces signals Pay attention in particular if the flash programmer's RESET signal is connected also to an on-board reset generation circuit. The reset output of the reset generator may ruin the flash programming process and may need to be isolated or disabled. V850 C Flash programmer RESET Reset generator RESET isolate or disable Figure 7-10 Potential conflict with RESET User's Manual U18743EE1V2UM00 273 Chapter 7 Flash Memory Ports The V850 port pins adopts following status during serial programming: Ports used for programming are configured as UART respectively CSI pins. All other pins remain in their default state after reset release. In case the default state after reset of the pins not used for programming is inport port or high -impedance output port, pay attention to other devices connected to these pins. If these devices require defined levels at the pins, the ports may have to be connected to VDD or VSS via a resistors. Oscillators 274 Connect all oscillator pins in the same way as in the normal operation mode. DRST During flash memory programming, input a low level to DRST or leave it open. Do not input a high level. Power supply Supply the same power to all power supply pins, including reference voltages, power regulator pins, etc., as in the normal operation mode. User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 (3) Selection of the communication mode The communication interface is chosen by applying a specified number of pulses to the FLMD0 pin after reset release. Note that this is handled by the flash programmer. Figure 7-11 on page 275 gives an example how the UART is established for the communication between the flash programmer and the microcontroller. VDD VDD VSS VDD RESET (input) VSS VDD FLMD1 (input) VSS VDD FLMD0 (input) VSS (Note) VDD RXD (input) VSS VDD TXD (output) Oscillation stabilized VSS Power on Figure 7-11 Note Table 7-8 FLMD0 pulses Communication mode selected Flash control command communication (erasure, write, etc.) Reset released Selection of communication mode The number of clocks to be inserted differs depending on the chosen communication mode. For details, refer to Table 7-8 on page 275. FLMD0 pulses for communication mode setting Communication Mode Remarks 0 UART Communication rate: 9600 bps (after reset), LSB first 8 CSI V850ES/Fx3-L performs slave operation, MSB first 11 CSI + HS V850ES/Fx3-L performs slave operation, MSB first Other - Setting prohibited When UART has been selected after reception of the FLMD0 pulses with 9600 bps, the flash programmer changes the baud rate according to the user's choice via the flash programmer's user interface. At first the programmer sends two 00H bytes, which are used by the microcontoller to measure the baud rate and to set up it's own baud rate accordingly. User's Manual U18743EE1V2UM00 275 Chapter 7 Flash Memory (4) Communication commands The flash programmer sends commands to the microcontroller. Depending on the commands, the microcontroller returns status information or the requested data. XXXXXX Command XXXX PG-FP4 (Flash Pro4) XXXXX STATVE XXX YYY XXXX YYYY Axxxx Bxxxxx Cxxxxxx Flash programmer Figure 7-12 Status Data V850 microcontroller Communication commands exchange The following table lists the flash memory control commands of the microcontroller. All these commands are issued by the flash programmer, and the microcontroller performs the corresponding processing. Table 7-9 Classification Flash memory control commands Command name Support CSIB CSIB + HS UARTD Function Blank check Block blank check command Checks erasure status of entire memory. Erase Chip erase command Erases all memory contents. Block erase command Erases memory contents of specified block. Write Write command Writes data by specifying write address and number of bytes to be written, and executes verify check. Verify Verify command Compares input data with all memory contents. System setting and control Reset command Escapes from each status. Oscillation frequency setting command Sets oscillation frequency. Baud rate setting command - - Sets baud rate when UART is used. Silicon signature command Reads silicon signature information. Version acquisition command Reads version information of device. Status command - Acquires operation status. Protection setting command Sets protection against chip erasure, block erasure, and writing. 276 User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 7.3 Code Flash Self-Programming This V850 microcontroller supports a flash macro service that allows the user program to rewrite the internal flash memory by itself. By using this flash macro service and a self-programming library, provided by NEC, the user's program is able to rewrite the flash memory with data, transferred in advance to the internal RAM. Thus the user program can be upgraded and constant data can be rewritten in the field. internal RAM User's re-programming routine Self-programming library Flash function execution Flash information Flash macro service Erase, write Flash memory Figure 7-13 Concept of self-programming During self-programming access to the flash memory is not possible. Thus program execution is only possible by instruction fetching from internal RAM. Consequently the instructions of user re-programming software routines, which shall remain in operation during the self-programming procedure, must be copied from the flash memory to the internal RAM prior to activating the selfprogramming. Since interrupt processing by using the interrupt vectors in the flash memory is also impossible during self-programming, a special feature is provided to re-route interrupt acknowledges to the internal RAM (refer to "Interrupt handling during flash self-programming" on page 283). It is recommended to refer to the application note "Self-Programming" (document nr. U16929EE) for comprehensive information concerning flash self-programming. This document explains also the functions of the selfprogramming library. The latest version of this document and the library can be loaded via the URL http://www.eu.necel.com User's Manual U18743EE1V2UM00 277 Chapter 7 Flash Memory 7.3.1 Self-programming enable The self-programming functions can be started out of the normal user mode of the microcontroller. The microcontroller must be set into self-programming mode via the selfprogramming library. For security reasons writing and erasing of the flash memory must be additionally permitted by setting the external FLMD0 pin to high level. Note that FLMD0 holds low level in normal operation mode after reset release. This requires some external components or wiring, e.g. connecting an output port to FLMD0. RESET signal VDD 0V Self-programming write/erase permitted VDD FLMD0 pin 0V Normal operation mode Figure 7-14 Normal operation mode Self-programming enable When self-programming has been completed, the voltage on the FLMD0 pin must be returned to VSS. 7.3.2 Self-programming library functions Code flash memory self-programming by the user's program is supported by the self-programming library. This library provides a set of C function calls to carry out basic functions like * blank-check/erase/rewrite/verify of the flash * boot cluster swapping, including definition of boot block clusters * definition of the variable reset vector * setting of protection flags * obtain various information concerning the code flash memory Detailed information how to use the library functions is given in the Application Note: "Self-Programming Library for embedded Single Voltage FLASH" (document no. U16929EE). The up-to-date version of the self-programming library and the above mentioned Application Note can be obtained from http://www.eu.necel.com. 278 User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 7.3.3 Secure self-programming (boot cluster swapping) The V850 flash microcontrollers support a mechanism to swap a cluster of code flash memory blocks, starting from address 0000 0000H, with another cluster of the same size, located immediately above the first one. Caution Boot cluster swapping is only supported, if the variable reset vector remains in its default state 0000 0000H. If the reset vector is changed to other values, boot cluster swapping is not possible. Boot swap cluster A group of boot blocks to be swapped. The cluster of blocks starting at address 0000 0000H is named active boot swap cluster, since it contains the entry point of the user's program at the default reset vector 0000 0000H. Boot swap flag Which of the two clusters is the active boot block cluster is controlled by the boot swap flag, that can be defined during flash programming via the selfprogramming library. The boot swap flag is stored in the flash memory extra area. Figure 7-15 on page 279 shows an example of the boot block swapping function with a cluster size of 4 flash memory blocks. After inverting the boot_flag - it becomes not(boot_flag) - blocks 4 to 7 become the active boot block cluster. Thus after next reset release the user's program starts from the new boot swap cluster. inactive boot swap cluster active boot swap cluster 0000 0000H Figure 7-15 last block last block block 8 block 8 block 7 block 3 block 6 block 2 block 5 block 1 block 4 block 0 block 3 block 7 block 2 block 6 block 1 block 5 block 0 block 4 boot_flag not(boot_flag) Boot swap cluster swapping function User's Manual U18743EE1V2UM00 279 Chapter 7 Secure selfprogramming Boot block cluster Flash Memory The boot cluster swapping function enables secure self-programming. In case the boot code shall be rewritten, the new code can be written to the inactive boot block cluster, while the boot_flag remains in its previous state. If rewriting of the boot block cluster has been completed successfully, the boot_flag can be inverted, making the new boot code active. If rewriting of the new boot code fails for any reason, e.g. power fail or unintended reset, the old boot code still remains active and rewriting can be started again. The boot code size itself may be smaller than the boot swap cluster size. The number of flash memory blocks, which are part of the boot code, are named boot block cluster. The number of boot blocks, which are member of the cluster, can be defined during self-programming via the self-programming library. The boot block cluster size determines the boot swap cluster size. This is automatically evaluated from the number of boot blocks, defined during selfprogramming. Table 7-10 on page 281 shows the relation between the number of boot blocks, the boot block cluster size and the boot swap cluster. Number of boot blocks 280 The numer of boot blocks has to be defined by the user during self-programming. It determines the blocks, which are subject to the boot block cluster protection, that allows to protect the boot blocks from any erase or write process. User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 Table 7-10 Number of boot blocksa Relation between boot block and boot swap cluster Devices with 2 KB blocks ( 256 KB code flash) 00H 0000 0000H - 0000 07FFH (2 KB) 01H RESV - 0000 0FFFH (4 KB) 02H RESV - 0000 17FFH (6 KB) 03H RESV - 0000 1FFFH (8 KB) 04H RESV - 0000 27FFH (10 KB) ... ... 07H RESV - 0000 3FFFH (16 KB) 08H RESV - 0000 47FFH (18 KB) ... ... 0FH RESV - 0000 7FFFH (max. 32 KB) 10H RESV - 0000 87FFH (34 KB) ... ... 1FH RESV - 0000 FFFFH (64 KB) 20H RESV - 0001 07FFH (66 KB) ... 7FH Boot swap cluster Boot block cluster 0000 0000H 0000 1FFFH (8 KB) 0000 0000H 0000 3FFFH (16 KB) 0000 0000H 0000 7FFFH (32 KB) 0000 0000H 0000 7FFFH (64 KB) ... RESV - 0003 FFFFH (256 KB) 80H ... Setting prohibited FFH a) The number of boot blocks has to be defined by the user during self-programming or via the external programmer during serial programming. User's Manual U18743EE1V2UM00 281 Chapter 7 Flash Memory Figure 7-16 on page 282 illustrates an example with following settings: * number of boot blocks: 2 (boot block cluster contains 2 blocks), thus the active boot block cluster comprises - if boot_flag: blocks 0and 1 - if not(boot_flag): blocks 4 and 5 * active boot swap clusters comprises - if boot_flag: blocks 0 to 3 - if not(boot_flag): blocks 4 to 7 inactive boot swap cluster active boot swap cluster 0000 0000H inactive boot block cluster active boot block cluster last block last block block 8 block 8 block 7 block 3 block 6 block 2 block 5 block 1 block 4 block 0 block 3 block 7 block 2 block 6 block 1 block 5 block 0 block 4 boot_flag not(boot_flag) Figure 7-16 Boot cluster swapping function Boot block protection To prohibit rewriting of the boot blocks, the boot block cluster protection flag can be set during flash memory programming. When this flag is set, the blocks of the active boot block cluster can neither be erased nor written. Boot cluster swapping is impossible as well. Note that only the blocks of the active boot block cluster are protected. In the example according to Figure 7-16 on page 282, for instance, blocks 0 and 1 would be prohibited, while blocks 2 and 3 could still be erased and written. Caution Once the boot block cluster protection has been activated, it can never be deactivated again. For further information concerning flash memory protection flags refer to "Data Protection and Security" on page 289. 282 User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 7.3.4 Interrupt handling during flash self-programming This microcontroller provides functions to maintain interrupt servicing during the self-programming procedure. Since neither the interrupt vector table nor the interrupt handler routines, which are normally located in the flash memory, are accessible while selfprogramming is active, interrupt acknowledges have to be re-routed to nonflash memory, i.e. to the internal RAM. Therefore two prerequisites are necessary to enable interrupt servicing during self-programming: * The concerned interrupt handler routine needs to be copied to the internal RAM. The user has to initiate this copy process. * The concerned interrupt acknowledge has to be re-routed to that handler. Re-routing to the handler is done by the internal firmware. Thus the user doesn't have to care about. The internal firmware and the self-programming library provide functions to initialize and process such interrupts. The interrupt handler routines can be copied from flash to the internal RAM by use of self-programming library functions. The addresses of the interrupt handler routines are set up via the selfprogramming library as well. Note 1. Note that this special interrupt handling adds some interrupt latency time. 2. Special interrupt handling is done only during the flash programming environment is activated. If self-programming is deactivated, the normal interrupt vector table in the flash memory is used. All interrupt vectors are relocated to one entry point in the internal RAM: * New entry point of all maskable interrupts is the 1st address of the internal RAM. A handler routine must check the interrupt source. The interrupt request source can be identified via the interrupt/exception source register ECR.EICC (refer to "System register set" on page 139) * New entry point of all non maskable interrupts is the word address following the maskable interrupt entry, i.e. the second address of the internal RAM. The interrupt request source can be identified via the interrupt/exception source register ECR.FECC (refer to"System register set" on page 139). In general a jump to a special handler routine will be placed at the 1st and 2nd internal RAM address, which identifies the interrupt sources and branches to the correct interrupt service routine. The function serving the interrupt needs to be compiled as an interrupt function (i.e. terminate with a RETI instruction, save/restore all used registers, etc.). It is recommended to refer to the application note "Self-Programming" (document nr. U16929EE) for comprehensive information concerning flash self-programming. This document explains also the functions of the selfprogramming library. The latest version of this document can be loaded via the URL http://www.eu.necel.com User's Manual U18743EE1V2UM00 283 Chapter 7 Flash Memory 7.4 Variable Reset Vector This microcontroller provides a facility to specify the address of the first user software instruction to be executed after reset release. By default the first user's instruction to be executed after reset, i.e. the reset vector, is the one stored at address 0000 0000H. During flash programming another reset vector address can be specified, the so called variable reset vector. The variable reset vector is stored in the flash memory extra area. The variable reset vector can be modified in all flash programming modes. The self-programming library supports this function. Note 284 The variable reset vector only determines the user's program start after reset. The vector table is not affected. It is always located at address 0000 0000H. User's Manual U18743EE1V2UM00 Flash Memory Chapter 7 7.5 Flash Mask Options In the option data area, a block subject to mask options is specified. Make sure to set the option data area corresponding to the following option bytes in the program at address 007AH/007BH as default data. Caution If the flash memory is programmed during a debug session with the on-chip debugger and the options bytes have been changed, a target reset command has to be issued in order to make the new option byte settings effective. User's Manual U18743EE1V2UM00 285 Chapter 7 Address Flash Memory Set Value 007AH Setting Internal oscilCan be stopped. lator: 00H WDT2: Sub oscillator: Count clock can be selected. Overflow signal can be selected from INTWDT2 or WDT2RES. Crystal resonator connection Internal oscilCannot be stopped. lator: 01H WDT2: Sub oscillator: Count clock can be selected. Overflow signal can be selected from INTWDT2 or WDT2RES. Crystal resonator connection Internal oscilCan be stopped. lator: 02H WDT2: Sub oscillator: Count clock is fixed to internal oscillator. Overflow signal is fixed to WDT2RES. Crystal resonator connection Internal oscilCannot be stopped. lator: 03H WDT2: Sub oscillator: Count clock is fixed to internal oscillator. Overflow signal is fixed to WDT2RES. Crystal resonator connection Internal oscilCan be stopped. lator: C0H WDT2: Sub oscillator: Count clock can be selected. Overflow signal can be selected from INTWDT2 or WDT2RES. RC oscillation connection Internal oscilCannot be stopped. lator: C1H WDT2: Sub oscillator: Count clock can be selected. Overflow signal can be selected from INTWDT2 or WDT2RES. RC oscillation connection Internal oscilCan be stopped. lator: C2H WDT2: Sub oscillator: Count clock is fixed to internal oscillator. Overflow signal is fixed to WDT2RES. RC oscillation connection Internal oscilCannot be stopped. lator: C3H WDT2: Sub oscillator: 286 Count clock is fixed to internal oscillator. Overflow signal is fixed to WDT2RES. RC oscillation User's Manual U18743EE1V2UM00 Flash Memory 0000 007BH Chapter 7 7 6 5 4 3 2 1 0 SUBCLK 0 0 0 PLLO PRSI PLLI1 PLLI0 PLLI1 PLLI0 0 0 fPLLI = fX 0 1 fPLLI = fx/2 1 x fPLLI = fx/4 PRSI Selection of PLL input clock to PLL Peripheral clock selection 0 fXP1,fXP2 = fXX 1 fXP1,fXP2 = fXX/2 PLLO PLL output clock selection 0 Setting prohibited 1 fPLL = fPLLO/2 SUBCLK Clock source at sublock operating mode 0 SubOSC selection 1 240 KHz internal oscillator selection User's Manual U18743EE1V2UM00 287 Chapter 7 Flash Memory 7.5.1 PRDSELH register - Product selection code register High The 16-bit PRDSELH register specifies the RAM start address of the device. Access Address Initial Value PRDSELH The register can be accessed in 16-bit units. FFFFFCCAH Device depending (for details see table below) 15 14 13 12 11 10 9 8 x x x x x x x x R R R R R R R R 7 6 5 4 3 2 1 0 x x x x RAM3 RAM2 RAM1 RAM0 R R R R R R R R RAM3 RAM2 RAM1 RAM0 288 RAM start address 0 0 0 1 03FFD800H 0 0 1 0 03FFD000H 0 0 1 1 03FFC000H 0 1 0 0 03FFB000H User's Manual U18743EE1V2UM00 Chapter 8 Data Protection and Security 8.1 Overview The microcontroller supports various methods for securing safe (re-)programming of the internal flash memory and protecting of the flash memory data against undesired access, such as illegal read-out or illegal reprogramming. Security functions Security functions provide countermeasures against unexpected failures during reprogramming processes. These are basically: * Secure self-programming * Secure bootloader update * Boot swapping * Boot block cluster protection These functions are described in detail in "Flash Memory" on page 259. Protection functions Protection functions provide a set of mechanisms to protect the internal flash memory data from being read, erased or altered by unauthorized persons. These are basically: * On-chip (N-Wire) debug interface protection * Flash memory erase/write/read protection via the serial programming interface Some interfaces offer in general access to the internal flash memory: N-Wire debug interface, external flash programmer interfaces and self-programming facilities. All of these interfaces need to be considered for a proper protection concept. The following sections give an overview about supported protection methods. 8.2 N-Wire Debug Interface Protection In general read-out of the flash memory contents is possible via the N-Wire debug interface, but protection against illegal read-out can be enabled. For protection of the flash memory, the usage of the debug interface can be protected and it can be disabled. The debug interface is protected via a 10-byte ID code and an internal flag (N-Wire use enable flag). When the debugger is started, the status of a flag is queried (N-Wire use enable flag). Set this flag to zero to disable the use of the N-Wire in-circuit emulator. When debugging is enabled (N-Wire use enable flag is set), you have to enter a 10-byte ID code via the debugger. The code is compared with the ID code stored in the internal flash memory. If the codes do not match, debugging is not possible. The N-Wire use enable flag can be set or reset while reprogramming the flash by an external flash writer or with the self-programming feature. The flag is located at bit 7 at address 0000 0079H. User's Manual U18743EE1V2UM00 289 Chapter 8 Data Protection and Security You can specify your own 10-byte ID code and program it to the internal flash memory by an external flash writer or with the self-programming feature. The ID code is located in the address range 0000 0070H to 0000 0079H. The protection levels are summarized in Table 8-1 Table 8-1 Possible results of ID code comparison N-Wire use enable flag ID code Protection Level 0 Xa Level 2: Full protection N-Wire debug interface cannot be used.b 1 user-specific ID code Level 1: ID code protection user ID code N-Wire debug interface can only be used if the user enters the correct ID code. ID code is all onesc Level 0: ID code protection with default ID code N-Wire debug interface can be used if the user enters the default ID code FFH for all ID bytes. a) b) c) Note 290 Codes are not compared Once the N-Wire debug interface has been set as "use-prohibited", it cannot be used until the flash memory is re-programmed. This is the default state after the flash memory has been erased. 1. After you have set protection levels 1 or 2, set the "block erase disable flag" in the flash extra area. Otherwise, an unauthorized person could erase the block that contains the ID code or the "N-Wire use enable flag", respectively, and thus suspend the protection. User's Manual U18743EE1V2UM00 Data Protection and Security Chapter 8 8.3 Flash Programmer and Self-Programming Protection In general, illegal read-out and re-programming of the flash memory contents is possible via the flash writer interface and the self-programming feature.The available flash memory protection methods are as follows. Serial programming Self-programming Protection flags It is possible to prohibit any access from external via the serial programming interface,e.g. by an external flash programmer. With maximum protection the internal flash memory can not be erased, read-out or written at all, neither in block units nor the entire flash memory. During self-programming all operations to erase, read or program the flash memory is under control of the user's program. Thus no further protection functions in self-programming mode are considered. One exception is the boot block protection, which applies also in self-programming mode. The protection flags can be set respectively reset by an external flash programmer, provided the effective protection level allows to do so. In self-programming mode the effective protection flags can not be reset, but other ones can be set to enhance the protection level. The protection flags are stored in the flash memory extra area. Each protection function can be used in combination with the others at the same time. (1) Write protection flag Set this flag to disable the programming function via external flash programmer interfaces. No flash memory content can be written from external, if this flag is set. Erasure of single blocks is prohibited as well. This flag does not affect the self-programming interface. In self-programming mode writing of the flash memory is further on possible. (2) Chip erase protection flag Set this flag to disable the chip erase function via external flash programmer interfaces. No flash memory content can be erased - neither in single blocks nor the entire flash memory - from external, if this flag is set. Chip erase is not available in self-programming mode, though it is possible to erase the entire flash memory content by block erase of all blocks all together. Note that the contents of the extra area is not erased by this means. I.e. protection flags, variable reset vector, etc. are still valid. (3) Block erase protection flag Set this flag to disable the feature to erase single blocks via external flash programmer interfaces. Single blocks can not be erased. Chip erase is still possible, provided the chip erase protection flag is not set. This flag does not affect the self-programming interface. In self-programming mode erasure of single blocks or sets of contiguous blocks of the flash memory is further on possible. User's Manual U18743EE1V2UM00 291 Chapter 8 Data Protection and Security (4) Read-out protection flag Set this flag to disable the feature that allows reading back the flash memory via external flash programmer interfaces. No flash content can be read out. This flag does not affect the self-programming interface. In self-programming mode read-out of flash memory content is further on possible. (5) Boot block cluster protection flag Set this flag to disable erasure and rewrite of the boot block cluster. The boot block cluster can not be manipulated in any way (no erase/write). This applies in serial and self-programming mode. Once this flag is set, it is impossible to reset this flag. Thus the boot block cluster content can not be changed any more. For the explanation of the boot block cluster refer to "Secure self-programming (boot cluster swapping)" on page 279. All protection flags are reset after shipment of the device, thus no protection is enabled at all. Once a protection flag has been set, i.e. the protection is effective, it can not be reset by any means, except after a chip erase, which erases the entire flash memory including the extra area. Consequently without prior chip erase the protection level can only be increased, but not decreased. Table 8-2 Function Protection functions overview Functional outline Applicable (: applies, x: doesn't apply) Serial programming Self-programming Block erase command prohibit Erasure of single blocks impossible. Once block erase protection is enabled, disable is only possible after chip erase. x Chip erase command prohibit Erasure of the entire flash (including the extra area) or single blocks impossible. Once chip erase protection is enabled, all protection flag settings can not be changed any more. x Program command prohibit Erasure and rewrite of single blocks impossible. Once write protection is enabled, disable is only possible after chip erase. x Read command prohibit Read-out of any flash content impossible. Once read protection is enabled, disable is only possible after chip erase. x Rewriting boot block cluster prohibit Erasure (by block or chip erase) or writing of the boot block cluster impossible. Once rewrite protection of the boot block cluster is enabled, it can not be disabled any more. 292 User's Manual U18743EE1V2UM00 Data Protection and Security Table 8-3 Chapter 8 Rewriting operation when erasing/writing is enabled/prohibited Block erasure Prohibition state Rewriting boot area enabled Rewriting boot area prohibited Programming mode All enabled None boot area Boot area Write Chip erasure None boot area Boot area Self-programming yes - yes Serial programming yes yes yes Block erase command prohibited Self-programming yes - yes Serial programming no yes yes Chip erase command prohibited Self-programming yes - yes Serial programming no no yes Write command prohibited Self-programming yes - yes Serial programming no yes no All enabled Self-programming yes - Serial programming yes no yes Block erase command prohibited Self-programming yes - yes Serial programming no yes yes Chip erase command prohibited Self-programming yes - yes Serial programming no no yes Write command prohibited Self-programming yes - yes Serial programming no yes no Note Table 8-4 no yes -: not supported Read operation when reading is enabled/prohibited Prohibition State Read command enabled Read command prohibited Note no Programming mode Read Self-programming Serial programming Self-programming Serial programming x : execution enabled, x: execution disabled, -: not supported User's Manual U18743EE1V2UM00 293 Chapter 8 294 Data Protection and Security User's Manual U18743EE1V2UM00 Chapter 9 Bus Control Unit (BCU) The Bus Control Unit BCU controls the access to on-chip peripheral I/Os. 9.1 Description The figure below shows a block diagram of the modules that are necessary for accessing the on-chip peripherals. VFB CPU VDB Bus Control Unit VSB Bus Bridge Internal Bus (NPB) On-chip Peripheral I/O Figure 9-1 Busses BCU Bus and Memory Control block diagram The busses are abbreviated as follows: * NPB: NEC peripheral bus * VSB: V850 system bus * VDB: V850 data bus * VFB: V850 fetch bus The Bus Control Unit (BCU) controls the access to the on-chip peripherals. . Preliminary User's Manual U18743EE1V2UM00 295 Chapter 9 Bus Control Unit (BCU) 9.1.1 Peripheral I/O area Two areas of the address range are reserved for the registers of the on-chip peripheral functions. These areas are called "peripheral I/O areas": Table 9-1 (1) Peripheral I/O areas Name Address range Size Fixed peripheral I/O area 03FF F000H to 03FF FFFH 4 KB Programmable peripheral I/O area (PPA) 03FE C000H to 03FE EFFFH 12 KB Fixed peripheral I/O area The fixed peripheral I/O area holds the registers of the on-chip peripheral I/O functions. Note 296 Because the address space covers 64 MB, the address bits A[31:26] are not considered. Therefore, in this manual, all addresses of peripheral I/O registers in the 4 KB peripheral I/O area are given in the range FFFF F000H to FFFF FFFFH instead of 03FF F000H to 03FF FFFFH. Preliminary User's Manual U18743EE1V2UM00 Bus Control Unit (BCU) (2) Chapter 9 Programmable peripheral I/O area (PPA) With this microcontroller, usage and address range of the PPA are not configurable. The PPA extends the fixed peripheral I/O area and assigns an additional 12 KB address space for accessing on-chip peripherals. The figure below illustrates the programmable peripheral I/O area (PPA). 03FF FFFFH 03FF F000H Peripheral I/O register (4 KB) NPB (NEC Peripheral Bus) same area 03FE EFFFH 03FE C000H Figure 9-2 Programmable peripheral I/O register Peripheral I/O area (4 KB) (12 KB) Programmable peripheral I/O area Dedicated area for FCAN controller Programmable peripheral I/O area The CAN modules registers and message buffers are allocated to the PPA. Refer to "CAN module register and message buffer addresses" on page 553 for information how to calculate the register and message buffer addresses of the CAN modules. Note 1. The fixed peripheral I/O area is mirrored to the upper 4 KB of the programmable peripheral I/O area. If data is written in one area, data having the same contents is also written in the other area. 2. To make software suitable for both microcontroller and emulation tool, it is recommended to include the set up of the base address in the software. See "BPC - Peripheral area selection control register" on page 301. Preliminary User's Manual U18743EE1V2UM00 297 Chapter 9 Bus Control Unit (BCU) 9.1.2 NPB access timing All accesses to the peripheral I/O areas are passed over to the NPB bus via the VSB - NPB bus bridge BBR. Read and write access times to registers via the NPB depend on the register (refer to "Registers Access Times" on page 749), the system clock VBCLK and the setting of the VSWC register. The CPU operation during an access to a register via the NPB depends also on the kind of peripheral I/O area: * Fixed peripheral I/O area During a read or write access the CPU operation stops until the access via the NPB is completed. * Programmable peripheral I/O area During a read access the CPU operation stops until the read access via the NPB is completed. During a write access the CPU operation continues operation, provided any preceded NPB access is already finished. If a preceded NPB access is still ongoing the CPU stops until this access is finished and the NPB is cleared. Caution Pay attention at write accesses to NPB peripheral I/O registers via the programmable peripheral I/O area. Since the CPU may continue operation, even though the data has not yet been transferred to its destination register, inconsistencies may occur between the program flow and the status of the registers. In particular register set-ups which change an operational status of a certain module require special notice, like, for instance, masking/unmasking of interrupts via maskable interrupt control registers xxIC, enabling/disabling timers, etc. 298 Preliminary User's Manual U18743EE1V2UM00 Bus Control Unit (BCU) Chapter 9 9.1.3 Bus properties This section summarizes the properties of the internal bus. (1) Bus access The number of CPU clocks necessary for accessing each resource is as follows: Table 9-2 number of bus access clocks Internal ROM (32 bits) Bus cycle configuration Instruction fetch with latency = 0 with latency = 1 Normal access 1 1 1a Branch 2 4 1 1 4 1 Operand data access a) Internal RAM (32 bits) In case of contention with data access, the instruction fetch from internal RAM takes 2 clocks. Note (2) Unit: Clocks/access Endian format The endian format is fixed to little endian format. The endian format defines the byte order in which word data is stored. "Little Endian" means that the low-order byte of the word is stored in memory at the lowest address, and the high-order byte at the highest address. Therefore, the base address of the word addresses the low-order byte: bit number 31 byte position access via addresses Figure 9-3 24 23 16 15 8 7 0 Byte 3 Byte 2 Byte 1 Byte 0 <base> + 3 <base> + 2 <base> + 1 <base> Little endian addresses within a word 9.1.4 Boundary operation conditions The microcontroller device has the following boundary operation conditions: (1) Program space Instruction fetches from the internal peripheral I/O area are inhibited and yield NOP operations. If a branch instruction exists at the upper limit of the internal RAM area, a pre-fetch operation (invalid fetch) that straddles over the internal peripheral I/O area does not occur. Preliminary User's Manual U18743EE1V2UM00 299 Chapter 9 Bus Control Unit (BCU) (2) Data space The microcontroller device is provided with an address misalign function. By this function, data of any format (word: 32 bit, halfword: 16 bit, byte: 8 bit) can be placed to any address in memory, even though the address is not aligned to the data format (that means address 4n for words, address 2n for halfwords). * Unaligned halfword data access When the LSB of the address is A0 = 1, two byte accesses are performed. * Unaligned word data access - When the LSB of the address is A0 = 1, two byte and one halfword accesses are performed. In total it takes 3 bus cycles. - When the LSBs of the address are A[1:0] =10B, two halfword accesses are performed. Note 300 Accessing data on misaligned addresses takes more than one bus cycle to complete data read/write. Consequently, the bus efficiency will drop. Preliminary User's Manual U18743EE1V2UM00 Bus Control Unit (BCU) Chapter 9 9.2 Registers Access to the on-chip peripherals is controlled and operated by registers of the Bus Control Unit (BCU): Table 9-3 Bus and memory control register overview Module Register name Shortcut Address Bus Control Unit (BCU) Peripheral area selection control register BPC FFFF F064H Internal peripheral function wait control register VSWC FFFF F06EH 9.2.1 BCU registers The following registers are part of the BCU. They define the usage of the programmable peripheral I/O area (PPA) and the data bus width. (1) BPC - Peripheral area selection control register The 16-bit BPC register enables/disables the PPA and it determines the starting address of the PPA. * For the microcontroller, the base address of the PPA is fixed to 03FE C000H. Thus writing to BPC.PA[13:0] does not change the PPA base address. Nevertheless the PPA must be enabled by setting BPC.PA15 = 1. * For the emulation tool, the PPA has to be enabled and the base address has to be set up by writing 8FFBH to the BPC register. To make software suitable for both microcontroller and emulation tool, it is recommended to include the set up of the PPA with BPC = 8FFBH in the software. Access Address Initial Value 15 14 PA15 0 13 12 This register can be read/written in 16-bit units. FFFF F064H 0000H 11 10 PA13 PA12 PA11 PA10 Table 9-4 Bit Position Bit Name 15 PA15 11 to 0 PA[13:0] Caution 9 8 7 6 5 4 3 2 1 0 PA9 PA8 PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 BPC register contents Function Select usage of programmable peripheral I/O area (PPA). 0: PPA disabled 1: PPA enabled Bits PA[13:0] specify bits 27 to 14 of the starting address of the PPA. The other bits of the address are fixed to 0. The bits marked with 0 must always be 0. The base address PBA of the programmable peripheral area sets the start address of the 16 KB PPA in a range of 256 MB. The 256 MB page is mirrored 16 times to the entire 32-bit address range. Preliminary User's Manual U18743EE1V2UM00 301 Chapter 9 Bus Control Unit (BCU) The base address PBA is calculated by PBA = BPC.PA[13:0] x 214 Table 9-5 shows how the addresses of the programmable peripheral area are assembled. The base address PBA is highlighted. Table 9-5 Address range of programmable peripheral area (12 KB) 31 ... 28 0 ... 0 27 ... BPC.PA[13:0] ... (2) 14 13 ... 1 ... ... 1 0 1 1 bit ... 0 ... 0 BPC.PA[13:0] 0 ... 0 1 0 ... 0 BPC.PA[13:0] 0 ... 0 0 PBA VSWC - Internal peripheral function wait control register The 8-bit VSWC register controls the bus access wait for the on-chip peripheral I/O registers. The data wait states are based on the system clock. Access to on-chip peripheral I/O registers is made in 3 clocks (without wait), however, waits may be required depending on the operation frequency. Set the values described below to the VSWC register in accordance with the operation frequency used. Access Address Initial Value This register can be read/written in 8-bit units. FFFF F06EH 77H 7 0 R Table 9-6 Bit position 6 5 4 SUWL2 SUWL1 SUWL0 R/W R/W R/W 3 2 1 0 0 VSWL2 VSWL1 VSWL0 R R/W R/W R/W VSWC register contents (1/2) Bit name Function Address setup wait for internal bus: 6 to 4 302 SUWL[2:0] SUWL2 SUWL1 SUWL0 Number of address setup wait states 0 0 0 0 0 0 1 1 CPU system clock (VBCLK) 0 1 0 2 CPU system clock (VBCLK) 0 1 1 3 CPU system clock (VBCLK) 1 0 0 4 CPU system clock (VBCLK) 1 0 1 5 CPU system clock (VBCLK) 1 1 0 6 CPU system clock (VBCLK) 1 1 1 7 CPU system clock (VBCLK) Preliminary User's Manual U18743EE1V2UM00 Bus Control Unit (BCU) Table 9-6 Bit position Chapter 9 VSWC register contents (2/2) Bit name Function Data wait for internal bus: 2 to 0 VSWL2 VSWL1 VSWL0 Number of data wait states 0 0 0 0 0 0 1 1 CPU system clock (VBCLK) 0 1 0 2 CPU system clock (VBCLK) 0 1 1 3 CPU system clock (VBCLK) 1 0 0 4 CPU system clock (VBCLK) 1 0 1 5 CPU system clock (VBCLK) 1 1 0 6 CPU system clock (VBCLK) 1 1 1 7 CPU system clock (VBCLK) VSWL[2:0] The following setups are recommended for VSWC: Table 9-7 Recommended timing for internal bus 16 MHz 20 MHz SUWL 0 0 VSWL 0 1 VSWC 00H 01H System clock (fCPU) Note 1. The bits marked with 0 must always be 0. 2. This register must be initialized after RESET. Preliminary User's Manual U18743EE1V2UM00 303 Chapter 9 304 Bus Control Unit (BCU) Preliminary User's Manual U18743EE1V2UM00 Chapter 10 16-Bit Timer/Event Counter AA The V850ES/Fx3-L microcontrollers have following instances of the 16-bit timer/event counter AA: TAA V850ES/ FE3-L V850ES/ FF3-L Instances Names V850ES/ FG3-L 5 TAA0 to TAA4 Throughout this chapter, the individual instances of Timer AA are identified by "n", for example, TAAnCTL0 for the TAAn control register 0. The timer is upward compatible to Timer P used in various other devices of the V850E and the V850ES family. It offers new additional features for enhanced output control 10.1 Features Timer AA (TAA) is a 16-bit timer/event counter provided with general-purpose functions. TAA can perform the following operations. * 16-bit-accuracy PWM output timer * Interval timer * External event counter function * Timer synchronised operation function withother Timers AA channels (refer to "Timer AA Synchroneous Operation" on page 377) * One-shot pulse output * Pulse interval and frequency measurement counter * Free running function * External trigger pulse output function * 32-bit capture timer function by cascading 2 channels of TAA User's Manual U18743EE1V2UM00 305 Chapter 10 16-Bit Timer/Event Counter AA 10.2 Function Outline * Capture trigger input signal x 2 * External trigger input signal x 1 * Clock select x 8 * External event count input x 1 * Readable counter x 1 * Capture/compare reload register x 2 * Capture/compare match interrupt x 2 * Timer output (TOAAn0, TOAAn1) x 2 * 32-bit capture by cascading two timer AA (TAA0+TAA1, TAA2+TAA3, TAA5+TAA6). 10.3 Configuration TAA includes the following hardware. Table 10-1 Timer TAA registers and external connections Item Configuration Timer register 16-bit counter Registers * TAAn timer capture/compare registers 0, 1 (TAAnCCR0, TAAnCCR1) * TAAn timer read buffer register (TAAnCNT) * CCR0 buffer register, CCR1 buffer register Input selection registers Selector control registers (SELCNT0, SELCNT3) Timer output TOAAn0, TOAAn1 Timer input TIAAn0, TIAAn1 Control registers * TAAn control registers 0, 1 (TAAnCTL0, TAAnCTL1) * TAAn I/O control registers 0 to 2 and 4 (TAAnIOC0 to TAAnIOC2, TAAnIOC4) * TAAn option registers 0, 1 (TAAnOPT0, TAAnOPT1) Timer AA (TAA) pins are alternate function of port pins. For how to set the alternate function, refer to the description of the registers in "Pin Functions" on page 31. The block diagram of the timer TAA is shown below. Figure 10-2 to Figure 10-3 show the block diagrams of the input circuits of the different timers TAAn. 306 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 Internal bus TAAnIOC2 TAAnESS1-0 TAAnCKS2-0 TAAnCSE TAAnCCR0 TAAnCNT0 CCR0 buffer register Selector TAAnCE fXP1 or fXP2 fXP1/2 or fXP2/2 fXP1/4 or fXP2/4 fXP1/8 fXP1/16 fXP1/32 fXP1/64 TAAnOPT1 TAAnETS1-0 Selector TAAnCTL0 TAAnCE Load INTTAAnCC0 fXP1/128 or fXP1/256 or fXT Counter control Edge detector Clear 16-bit counter CCR1 buffer register Trigger control Edge detector TAAnCE INTTAAnOV Selector Input circuit (see separate figure) Edge detector Load INTTAAnCC1 TAAnCCR1 Capture/compare selection function Edge detector Output controller TAAnIS3-0 TAAnIOC1 TAAnSYE TAAnEST TAAnEEE TAAnCTL1 TAAnMD2-0 TAAnCCS1-0 TAAnOPT0 TOAAn0 TOAAn1 TAAnOVF TAAnIOC0 TAAnIOC4 Internal bus Figure 10-1 Block diagram of Timer AA User's Manual U18743EE1V2UM00 307 Chapter 10 16-Bit Timer/Event Counter AA TIAA00 TSOUT from CAN0 Edge detector RXDD0 TIAA01 Edge detector RXDD1 TIAA10 Edge detector TIAA11 Edge detector INTTM0EQ0 SELCNT0 SELCNT0 Internal bus Internal bus Figure 10-2 Input circuit of TAA0 (left) and TAA1 (right) TIAA30 Edge detector RXDD2 Edge detector TIAA31 SELCNT0 Internal bus Figure 10-3 308 Input circuit of TAA3 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (1) Chapter 10 TAAnCCR0 - TAA capture/compare register 0 The TAAnCCR0 register is a 16-bit register that operates either as capture register or as a compare register. In free-running mode, this register can be used as a capture register or as a compare register specified by bit TAAnOPT0.TAAnCCS0. In the pulse width measurement mode, this register can be used only as a capture register (the compare function cannot be used.) In all modes other than free-running mode and pulse width measurement mode, this register is used as a compare register. This register can be read/written in 16-bit units. After a RESET, TAAnCCR0 register default status is compare register. RESET input clears this register to 0000H. Caution Address: 15 14 When external event counter mode is used, do not set TAAnCCR0 register to 0000H. TAA0CCR0 FFFFF596H, TAA1CCR0 FFFFF5A6H, TAA2CCR0 FFFFF5B6H, TAA3CCR0 FFFFF5C6H, TAA4CCR0 FFFFF5D6H 13 12 11 10 9 8 7 6 5 4 3 2 1 TAAnCCR0 0 R/W After reset R/W 0000H * When used as a compare register, TAAnCCR0 can be rewritten when TAAnCE = 1, as shown below: TAA operation mode TAAnCCR0 register writing method PWM mode, external trigger pulse output mode Reload Free-running mode, external event count mode, one-shot pulse mode, interval timer mode Any time write Pulse width measurement mode Not applicable (used as capture register) * When used as capture register, the count value is stored in TAAnCCR0 upon capture trigger (TIAAn0) input edge detection. Note 1. The value of TAAnCCR0 register can be read/written when TAAnCE bit of TAAn control register 0 (TAAnCTL0) equals 1. 2. Access to the TAAnCCR0 register is prohibited when the main clock is stopped in the subclock mode. User's Manual U18743EE1V2UM00 309 Chapter 10 16-Bit Timer/Event Counter AA (2) TAAnCCR1 - TAA capture/compare register 1 The TAAnCCR1 register is a 16-bit register that operates either both as a capture register or as a compare register. In free-running mode, this register can be used as a capture register or as a compare register specified by bit TAAnOPT0.TAAnCCS1. In the pulse width measurement mode, this register can be used only as a capture register (the compare function cannot be used.) In all modes other than free-running mode and pulse width measurement mode, this register is used as a compare register. After RESET, TAAnCCR1 register default status is compare register. RESET input clears this register to 0000H. Caution Address: 15 14 When external event counter mode is used, do not set TAAnCCR1 register to 0000H. TAA0CCR1 FFFFF598H, TAA1CCR1 FFFFF5A8H, TAA2CCR1 FFFFF5B8H, TAA3CCR1 FFFFF5C8H, TAA4CCR1 FFFFF5D8H 13 12 11 10 9 8 7 6 5 4 3 2 1 TAAnCCR1 0 R/W After reset R/W 0000H * When used as a compare register TAAnCCR1 can be rewritten when TAAnCE = 1, as below mentioned. TAA operation mode TAAnCCR1 register writing method PWM mode, external trigger pulse output mode Reload Free-running mode, external event count mode, one-shot pulse mode, interval timer mode Any time write Pulse width measurement mode Not applicable (used as capture register) * When used as a capture register Count value is stored in TAAnCCR1 upon capture trigger (TIAAn1) input edge detection. Note 1. The value of TAAnCCR1 register can be read/written when TAAnCE bit of TAAn control register 0 (TAAnCTL0) equals 1. 2. Access to the TAAnCCR1 register is prohibited when the main clock is stopped in the subclock mode. 310 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (3) Chapter 10 TAAnCNT - TAA counter read buffer register TAAnCNT register is a read buffer register that can read 16-bit counter values. This register is read-only, using a 16-bit memory manipulation instruction. RESET input sets this register to 0000H. When TAAnCE bit of TAAnCTL0 equals 0, 0000H is read from this register. The value of the register is read when TAAnCE bit = 1. Address: 15 14 TAA0CNT FFFFF59AH, TAA1CNT FFFFF5AAH, TAA2CNT FFFFF5BAH, TAA3CNT FFFFF5CAH, TAA4CNT FFFFF5DAH 13 12 11 10 9 8 7 TAAnCNT User's Manual U18743EE1V2UM00 6 5 4 3 2 1 0 R/W After reset R 0000H 311 Chapter 10 16-Bit Timer/Event Counter AA 10.4 Input Selection Registers These registers are used to select the inputs to timers. Note 1. In this section, only the bits that refer to Timer AA input selections are described. For further information concerning the other bits please refer to "Clock Generator" on page 179. 2. Enable the related peripheral function only after setting/changing the SELCNTn registers. (1) Access Address Initial Value SELCNT0 - Selector control register 0 This register can be read/written in 8-bit or 1-bit units. FFFF F308H. 00H. This register is initialized by any reset. * V850ES/FE3-L * V850ES/FF3-L 7 6 5 4 3 2 ISEL04 ISEL03 ISEL02 1 0 ISEL07 0 0 0 ISEL00 R/W R R R/W R/W R/W R R/W 5 4 3 2 1 0 0 ISEL00 R R/W * V850ES/FG3-L Note Table 10-2 7 6 ISEL07 0 R/W R ISEL05 ISEL04 ISEL03 ISEL02 R/W R/W R/W "R" bits marked with "0" must not be changed from their default value "0". SELCNT0 register contents Bit position Bit name 7 ISEL07 6 ISEL06 Selection of TIAA31: 0: TIAA31 pin 1: RXDD3 pin 5 ISEL05 Selection of TIAA30: 0: TIAA30 pin 1: RXDD2 pin 4 ISEL04 Selection of TIAA11: 0: TIAA11 pin 1: RXDD1 pin 3 ISEL03 Selection of TIAA10: 0: TIAA10 pin 1: RXDD0 pin 2 ISEL02 Selection of TIAA01: 0: TIAA01 pin 1: INTTM0EQ0 signal from TMM 0 ISEL00 Selection of TIAA00: 0: TIAA00 pin 1: TSO UT signal from CAN0 312 R/W Function Refers to Clock Generator User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Note (2) Access Address Initial Value Chapter 10 If the INTTM0EQ0 interrupt signal is used for the TIAA01 input signal, use in the following range. TMM operation clock period TAA operation clock period x 4 SELCNT3 - Selector control register 3 This register can be read/written in 8-bit or 1-bit units. FFFF F30EH. 00H. This register is initialized by any reset. * V850ES/FG3-L Note Table 10-3 Bit position Bit name 2 ISEL32 7 6 5 4 3 2 1 0 0 0 0 0 0 ISEL32 0 0 R R R R R R/W R R "R" bits marked with "0" must not be changed from their default value "0". SELCNT3 register contents Function Refers to Clock Generator User's Manual U18743EE1V2UM00 313 Chapter 10 16-Bit Timer/Event Counter AA 10.5 Control Registers (1) TAAnCTL0 - TAA control register 0 TAAn control register 0 is an 8-bit register that controls the operation of timer AA. This register can be read and written in 8-bit or 1-bit units. RESET input clears this register to 00H. The TAAnCTL0 register is prohibited from writing during operation (TAAnCE=1). However, the TAAnCE bit can be rewritten. Address: TAA0CTL0 FFFFF590H, TAA1CTL0 FFFFF5A0H, TAA2CTL0 FFFFF5B0H, TAA3CTL0 FFFFF5C0H, TAA4CTL0 FFFFF5D0H Symbol 7 6 5 4 3 2 1 0 TAAnCTL0 TAAn CE 0 0 0 0 TAAn CKS2 TAAn CKS1 TAAn CKS0 TAAnCE R/W After reset R/W 00H Timer AAn operation control 0 Disable internal operating clock operation (TAAn is asynchronously reseted) 1 Enable internal operating clock operation Internal operating clock control and TAAn asynchronous reset are performed with the TAAnCE bit. When TAAnCE bit is cleared to 0, the internal operating clock of TAAn stops (fixed to low level) and TAAn is reset asynchronously. When the TAAnCE bit is set to 1, the internal operating clock is enabled within 2 input clocks, and TAAn counts up. Note In the following modes TAAnCTL0.TAAnCE cannot be set to "1": * Slave timer in synchroneous operation mode If the timer is operated as the slave timer in synchroneous operation mode, i.e. TAAnCTL1.TAAnSYE = 1. * Slave timer in 32-bit cascaded capture mode If timer TAAn is operated in 32-bit capture mode for capturing the upper 16 bit, i.e. TAAnOPT1.TAAnCSE = 1 (n = 1, 3). 314 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 Selection of internal count clock TAAnCTL0 register SELCNT2.ISEL2[4:0] TAAn TAAn TAAn CKS2 CKS1 CKS0 0 n = 1, 3 PRSI = 0 PRSI = 1 PRSI = 0 PRSI = 1 fXP1 fXX fXX/2 fXX fXX/2 fXP2a fXX fXX/2 fXX fXX/2 fXP1/2 fXX/2 fXX/4 fXX/2 fXX/4 fXP2/2 fXX/2 fXX/4 fXX/2 fXX/4 fXP1/4 fXX/4 fXX/8 fXX/4 fXX/8 fXP2/4 fXX/4 fXX/8 fXX/4 fXX/8 0 0 0 0 0 1 0 1 0 X 0 1 1 fXP1/8 fXX/8 fXX/16 fXX/8 fXX/16 X 1 0 0 fXP1/16 fXX/16 fXX/32 fXX/16 fXX/32 X 1 0 1 fXP1/32 fXX/32 fXX/64 fXX/32 fXX/64 X 1 1 0 fXP1/64 fXX/64 fXX/128 fXX/64 fXX/128 X 1 1 1 fXP1/128 fXX/128 fXX/256 - - fXT - - fXT fXT 1 0 1 0 1 a) n = 0, 2, 4 Input fXP2 has the same frequency as fXX, but doesn't stop in IDLE1 mode. Refer to "Clock Generator" on page 179 for details. Note Caution 1. PRSI can be set by the option bytes: Refer to "Flash Memory" on page 259 for details. Set bits TAAnCKS2 to TAAnCKS0 only when TAAnCE = 0. When TAAnCE bit setting is changed from 0 to 1, TAAnCKS2 to TAAnCKS0 bits can be set simultaneously. When the main clock is stopped, the count operation with the subclock is not available. User's Manual U18743EE1V2UM00 315 Chapter 10 16-Bit Timer/Event Counter AA (2) TAAnCTL1 - TAA timer control register 1 TAAn control register 1 is an 8-bit register that controls the operation of timer AA. This register can be read and written in 8-bit or 1-bit units. RESET input clears this register to 00H. Address: TAA0CTL1 FFFFF591H, TAA1CTL1 FFFFF5A1H, TAA2CTL1 FFFFF5B1H, TAA3CTL1 FFFFF5C1H, TAA4CTL1 FFFFF5D1H Symbol 7 6 5 4 3 2 1 0 TAAnCTL1 TAAn SYE TAAn EST TAAn EEE 0 0 TAAn MD2 TAAn MD1 TAAn MD0 TAAnSYE 0 R/W After reset R/W 00H Synchroneous operation mode enable control Independent operation mode (asynchronous operation mode) Synchroneous operation mode (specification of slave operation) In this mode, timer AA can operate in synchronization with a master timer. If TAAnSYE = 1, TAAnCTL0.TAAnCE cannot be set to "1". For the synchroneous operation mode, refer to "Timer AA Synchroneous Operation" on page 377. 1 Caution: Be sure to clear the TAAnSYE to 0, if TAAn is used as the master timer Respectively, set the TAAnSYE = 1, if TAAn is used as slave timer. TAAnEST 0 1 Software trigger control No operation In one-shot pulse mode: One-shot pulse software trigger In external trigger pulse output mode: Pulse output software trigger The TAAnEST bit functions as a software trigger in the one-shot pulse mode or external trigger pulse output mode (this bit is invalid in any other mode). By setting TAAnEST to 1 when TAAnCE = 1, a software trigger is issued. Therefore, be sure to set TAAnEST to 1 after setting TAAnCE = 1. The TIAAn0 pin is used for an external trigger. The read value of the TAAnEST bit is always 0. TAAnEEE Count clock selection 0 Use the internal clock (clock selected with TAAnCKS2 to TAAnCKS0 bits of TAAnCTL0 register) 1 Use external clock (input edge of TIAAn0) The valid edge is specified with TAAnEES1 and TAAnEES0 bits when TAAnEEE bit = 1 (external clock TIAAn0). 316 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Caution Chapter 10 TAAnMD2 TAAnMD1 TAAnMD0 Timer mode selection 0 0 0 Interval timer mode 0 0 1 External event counter mode 0 1 0 External trigger pulse output mode 0 1 1 One-shot pulse mode 1 0 0 PWM mode 1 0 1 Free-running mode 1 1 0 Pulse width measurement mode 1 1 1 Setting prohibited 1. Set bits TAAnEEE and TAAnMD2 to TAAnMD0 when TAAnCE = 0. (The same value can be written when TAAnCE = 1.) The operation is not guaranteed when rewriting is performed when TAAnCE = 1. If rewriting was mistakenly performed, clear TAAnCE to 0 and then set the bits again. 2. In the external event count mode the external event count input is selected regardless of the value of theTAAnEEE bit. 3. Set the count clock to internal clock (TAAnEEE = 0) when you use an external trigger pulse mode, the single shot pulse mode, and the pulse length measurement mode. 4. Set the edge detection of the TIAAn0 capture input to no detection when you use an external event count mode (TAAnEES1 of the TAAnIOC2 register and TAAnEES0 = 00). User's Manual U18743EE1V2UM00 317 Chapter 10 16-Bit Timer/Event Counter AA (3) TAAnIOC0 - TAA dedicated I/O control register 0 The TAAnIOC0 register is an 8-bit register that controls the timer output. This register can be read and written in 8-bit or 1-bit units. RESET input clears this register to 00H. Address: TAA0IOC0 FFFFF592H, TAA1CTL0 FFFFF5A2H, TAA2IOC0 FFFFF5B2H, TAA3IOC0 FFFFF5C2H, TAA4IOC0 FFFFF5D2H Symbol 7 6 5 4 3 2 1 0 TAAnIOC0 0 0 0 0 TAAn OL1 TAAn OE1 TAAn OL0 TAAn OE0 TAAnOLm R/W After reset R/W 00H TOAAnm output level setting 0 Normal output 1 Inverted output This bit can be used to invert the timer output TAAnOEm Caution TOAAnm output setting 0 Timer output is disabled (Low level and high level are output from TOAAnm pin when TAAnOLm = 0 and TAAnOLm = 1, respectively.) 1 Timer output is enabled (TOAAnm pin outputs pulses.) 1. Rewrite bits TAAnOLm and TAAnOEm when TAAnCE = 0 (the same value can be written when TAAnCE = 1.). If rewriting was mistakenly performed, clear TAAnCE to 0 and then set the bits again. 2. To enable the timer output, be sure to set the corresponding alternatefunction pins TAAnIS3 to TAAnIS0 of the TAAnIOC1 register to "No edge detection" and invalidate the capture operation. Then set the corresponding alternate-function port to output mode. Note 318 m = 0, 1 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (4) Chapter 10 TAAnIOC1 - TAA dedicated I/O control register 1 The TAAnIOC1 register is an 8-bit register that controls the valid edge for the external input signals (TIAAn0 and TIAAn1). This register can be read and written in 8-bit or 1-bit units. RESET input clears this register to 00H. Address: TAA0IOC1 FFFFF593H, TAA1IOC1 FFFFF5A3H, TAA2IOC1 FFFFF5B3H, TAA3IOC1 FFFFF5C3H, TAA4IOC1 FFFFF5D3H Symbol 7 6 5 4 3 2 1 0 TAAnIOC1 0 0 0 0 TAAn IS3 TAAn IS2 TAAn IS1 TAAn IS0 Caution R/W After reset R/W 00H TAAnIS3 TAAnIS2 Capture input (TIAAn1) valid edge setting 0 0 No edge detection (capture operation is invalid) 0 1 Detection of rising edge 1 0 Detection of falling edge 1 1 Detection of both edges TAAnIS1 TAAnIS0 0 0 No edge detection (capture operation is invalid) 0 1 Detection of rising edge 1 0 Detection of falling edge 1 1 Detection of both edges Capture input (TIAAn0) valid edge detection 1. Bits TAAnIS3 to TAAnIS0 are valid only in the free-running capture mode and pulse width measurement mode. In all the other modes, capture operation is not performed. 2. If used as the capture input, be sure to set the corresponding alternatefunction pins TAAnOE1 and TAAnOE0 of the TAAnIOC0 register to "Timer output is disabled" and set the capture input valid edge. Then set the corresponding alternate-function port to input mode. 3. In the external event count mode (TAAnCTL1.TAAnEEE = 1), set the TIAAn0 capture input to "No edge detection" (TAAnIS1 and TAAnISO bits = 00). User's Manual U18743EE1V2UM00 319 Chapter 10 Rewrite during timer operation 16-Bit Timer/Event Counter AA If the edge specification for the capture operation shall be changed, while the timer remains in operation (TAAnCTL0.TAAnCE = 1), only a single bit of the edge specification bits TAAnIOC1.TAAnIS[k:i] of a dedicated capture input may be changed with a single write operation. Consequently proceed as follows (TIAAn0 is used exemplarily): * Change from rising edge to falling edge: - current status is TAAnIOC1.TAAnIS[1:0] = 01B: "rising edge" - set TAAnIOC1.TAAnIS[1:0] = 00B: specify "no edge" - set TAAnIOC1.TAAnIS[1:0] = 10B: specify "falling edge" * Change from falling edge to rising edge: - current status is TAAnIOC1.TAAnIS[1:0] = 10B: "falling edge" - set TAAnIOC1.TAAnIS[1:0] = 00B: specify "no edge" - set TAAnIOC1.TAAnIS[1:0] = 01B: specify "rising edge" * Change from rising or falling edge to both edges: - current status is TAAnIOC1.TAAnIS[1:0] = 01B or 10B: "rising" or "falling edge" - set TAAnIOC1.TAAnIS[1:0] = 11B: specify "both edges" 320 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (5) Chapter 10 TAAnIOC2 - TAA I/O control register 2 The TAAnIOC2 register is an 8-bit register that controls the valid edge for external event count input signals (TIAAn0) and external trigger input signal (TIAAn0). This register can be read and written in 8-bit or 1-bit units. RESET input clears this register to 00H. Address: TAA0IOC2 FFFFF594H, TAA1IOC2 FFFFF5A4H, TAA2IOC2 FFFFF5B4H, TAA3IOC2 FFFFF5C4H, TAA4IOC2 FFFFF5D4H Symbol 7 6 5 4 3 2 1 0 TAAn IOC2 0 0 0 0 TAAn EES1 TAAn EES0 TAAn ETS1 TAAn ETS0 Caution R/W After reset R/W 00H External event count input valid edge setting (TIAAn0) TAAnEES1 TAAnEES0 0 0 No edge detection(external event count is invalid). 0 1 Detection of rising edge 1 0 Detection of falling edge 1 1 Detection of both edges TAAnETS1 TAAnETS0 0 0 No edge detection (external trigger is invalid). 0 1 Detection of rising edge 1 0 Detection of falling edge 1 1 Detection of both edges External trigger input valid edge detection (TIAAn0) 1. Rewrite TAAnEES1, TAAnEES0, TAAnETS1, and TAAnETS0 bits when TAAnCE = 0 (the same value can be written when TAAnCE = 1). If rewriting was mistakenly performed, clear TAAnCE to 0 and then set the bits again. 2. TAAnEES1 and TAAnEES0 bits are valid only when TAAnEEE = 1 or when the external event count mode has been set (TAAnCTL1.TAAnMD[2:0] = 001B). 3. TAAnETS1 and TAAnETS0 bits are only valid when the external trigger pulse output mode or one-shot pulse mode is set (TAAnMD[2:0] = 010B or 011B). User's Manual U18743EE1V2UM00 321 Chapter 10 Rewrite during timer operation 16-Bit Timer/Event Counter AA If the edge specification for the external event count input and external trigger input shall be changed, while the timer remains in operation (TAAnCTL0.TAAnCE = 1), only a single bit of the edge specification bits TAAnIOC2.TAAnEES[k:i] / TAAnIOC2.TAAnETS[k:i] of a dedicated capture input may be changed with a single write operation. Consequently proceed as follows (TIAAn0 is used exemplarily): In external event counter mode: * Change from rising edge to falling edge: - current status is TAAnIOC2.TAAnEES[1:0] = 01B: "rising edge" - set TAAnIOC2.TAAnEES[1:0] = 00B: specify "no edge" - set TAAnIOC2.TAAnEES[1:0] = 10B: specify "falling edge" * Change from falling edge to rising edge: - current status is TAAnIOC2.TAAnEES[1:0] = 10B: "falling edge" - set TAAnIOC2.TAAnEES[1:0] = 00B: specify "no edge" - set TAAnIOC2.TAAnEES[1:0] = 01B: specify "rising edge" * Change from rising or falling edge to both edges: - current status is TAAnIOC2.TAAnEES[1:0] = 01B or 10B: "rising" or "falling edge" - set TAAnIOC2.TAAnEES[1:0] = 11B: specify "both edges" In external trigger mode: * Change from rising edge to falling edge: - current status is TAAnIOC2.TAAnETS[1:0] = 01B: "rising edge" - set TAAnIOC2.TAAnETS[1:0] = 00B: specify "no edge" - set TAAnIOC2.TAAnETS[1:0] = 10B: specify "falling edge" * Change from falling edge to rising edge: - current status is TAAnIOC2.TAAnETSS[1:0] = 10B: "falling edge" - set TAAnIOC2.TAAnETS[1:0] = 00B: specify "no edge" - set TAAnIOC2.TAAnEtS[1:0] = 01B: specify "rising edge" * Change from rising or falling edge to both edges: - current status is TAAnIOC2.TAAnETS[1:0] = 01B or 10B: "rising" or "falling edge" - set TAAnIOC2.TAAnETS[1:0] = 11B: specify "both edges" Ensure the input level is not changing while the TAAnIOC2 register is modified. 322 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (6) Chapter 10 TAAnIOC4 - TAA I/O control register 4 The TAAnIOC4 register is an 8-bit register that controls the output function of Timer AA. This register can be read and written in 8-bit or 1-bit units. RESET input clears this register to 00H. Address: TAA0IOC4 FFFFF59CH, TAA1IOC4 FFFFF5ACH, TAA2IOC4 FFFFF5BCH, TAA3IOC4 FFFFF5CCH, TAA4IOC4 FFFFF5DCH Symbol 7 6 5 4 3 2 1 0 TAAnIOC4 0 0 0 0 TAAn OS1 TAAn OR1 TAAn OS0 TAAn OR0 Note R/W After reset R/W 00H TAAnOS1 TAAnOR1 Toggle Control of TOAAn1 0 0 Standard operation. 0 1 Force output level to inactive at next toggle event 1 0 Force output level to active at next toggle event 1 1 Freeze current output level. TAAnOS0 TAAnOR0 0 0 Standard operation. 0 1 Force output level to inactive at next toggle event 1 0 Force output level to active at next toggle event 1 1 Freeze current output level. Toggle Control of TOAAn0 1. After forcing the output level to either active or inactive, the TOAAn1 (TOAAn0) maintains this level (i.e. no toggling afterwards) until the TAAnOS1 (TAAnOS0) and TAAnOR1 (TAAnOR0) are cleared to standard operation. 2. The forcing of an output level is executed at the time of the next upcoming toggle event, while the freeze becomes effective immediately. 3. Writing to TAAnIOC4 is also possible, when TAAnCTL0.TAAnCE = 1. 4. The TAAnIOC4 register can be used in the interval mode or the free running mode. In other modes set this register to 00H. 5. In the free running mode, the setting's of the TAAnIOC4 register becomes effective only if the compare function is selected. When the capture function is selected, it is invalid. User's Manual U18743EE1V2UM00 323 Chapter 10 16-Bit Timer/Event Counter AA (7) TAAnOPT0 - TAA option register 0 The TAAnOPT0 register is an 8-bit register used to set the capture/compare operation and detect overflow. This register can be read and written in 8-bit or 1-bit units. RESET input clears this register to 00H. Address: TAA0OPT0 TAA2OPT0 TAA4OPT0 TAA6OPT0 FFFFF595H, TAA1OPT0 FFFFF5B5H, TAA3OPT0 FFFFF5D5H, TAA5OPT0 FFFFF5F5H, TAA7OPT0 FFFFF5A5H, FFFFF5C5H, FFFFF5E5H, FFFFF605H Symbol 7 6 5 4 3 2 1 <0> TAAnOPT0 0 0 TAAn CCS1 TAAn CCS0 0 0 0 TAAn OVF TAAnCCS1 R/W After reset R/W 00H TAAnCCR1 register capture/compare selection 0 Compare register selection 1 Capture register selection The TAAnCCS1 bit setting is valid only in the free-running mode. TAAnCCS0 TAAnCCR0 register capture/compare selection 0 Compare register selection 1 Capture register selection The TAAnCCS0 bit setting is valid only in the free-running mode. TAAnOVF Timer AA overflow detection Set (1) Overflow occurrence Reset (0) TAAnOVF bit write or TAAnCE = 0 * The TAAnOVF bit is set when the 16-bit counter value overflows from FFFFH to 0000H in the free-running mode and the pulse width measurement mode. * An interrupt request signal (INTTAAnOV) is generated as soon as TAAnOVF bit is set (1). The INTTAAnOV signal is not generated in any mode other than free-running mode and the pulse width measurement mode. * The TAAnOVF bit is not cleared even when the TAAnOVF bit and the TAAnOPT0 register are read when TAAnOVF = 1. * The TAAnOVF bit can be both read and written, but 1 cannot be written to the TAAnOVF bit from the CPU. Writing 1 has no influence on timer AA operation. Caution 324 Rewrite TAAnCCS1 and TAAnCCS0 bits when TAAnCE = 0 (the same value can be written when TAAnCE = 1.). If rewriting was mistakenly performed, clear TAAnCE to 0 and then set the bits again. User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (8) Chapter 10 TAAnOPT1 - TAA option register 1 The TAAnOPT1 register is an 8-bit register used to set the 32-bit capture mode by cascading two Timer AA. This register can be read and written in 8-bit or 1-bit units. RESET input clears this register to 00H. Address: TAA1OPT1 FFFFF5ADH, TAA3OPT1 FFFFF5CDH Symbol 7 6 5 4 3 2 1 <0> TAAnOPT1 TAAn CSE 0 0 0 0 0 0 0 Note After reset R/W 00H n = 1, 3 TAAnCSE Note R/W TAAnCCR1 register capture/compare selection 0 16-bit non-cascaded mode 1 Set 32-bit cascaded capture mode. Timer AAn becomes the upper 16bit and slave. The master timer is TAAm with m = n - 1. 1. When setting TAAnCSE, the timer becomes the upper 16-bit of a 32-bit timer. 2. If TAAnCSE = 1, TAAnCTL0.TAAnCE is forced to "0". 3. Cascading is only available for capture with free-running counter. 4. The following pairs of timers can be cascaded: * TAA0 and TAA1 (TAA0 will become master and will hold the lower 16-bit value) * TAA2 and TAA3 (TAA2 will become master and will hold the lower 16-bit value) The table below shows the effects of the TAAnCSE flag on the timer operation: TAAnCSE=0 TAnCSE=1 Operating clock macro clock from clock tree macro clock of TAAm Count Enable TAAnCE bit of TAAnCTL0 TAAmCE bit of TAAm Count Clock selected by TAAnCKS[2:0] Counter overflow from TAAm Capture Signal 0 TIAAn0 input with edge filter as selected by TAAnIS[1:0] TIAAm0 with edge filter selected for TAAm Capture Signal 1 TIAAn1 input with edge filter as selected by TAAnIS[3:2] TIAAm1 with edge filter selected for TAAm Capture Interrupt INTTAAnCC0 or INTTAAnCC1 INTTAAmCC0 or INTTAAmCC1 n=1 or 3; m= (n-1). For details on the 32-bit capture mode, please refer to "32-bit Capture in FreeRunning Cascade Mode" on page 363. User's Manual U18743EE1V2UM00 325 Chapter 10 16-Bit Timer/Event Counter AA 10.6 Operation Timer AA can perform the following operations when not in cascade mode: Operation TAAnEST Software trigger bit TIAAn0 External trigger input TAAnEEE Count clock selection Capture/ Compare Selection Compare Write Interval timer mode Invalid Invalid Internal/TIAAn0 pin Compare only Any time write External event counter mode Invalid Invalid External only Compare only Any time write External trigger pulse output modeNote Valid Valid Internal only Compare only Reload One-shot pulse output modeNote Valid Valid Internal only Compare only Any time write PWM mode Invalid Invalid Internal/TIAAn0 pin Compare only Reload Free-running mode Invalid Invalid Internal/TIAAn0 pin Capture/compare selectable Any time write Pulse width measurement modeNote Invalid Invalid Internal only Capture only Not applicable Note 1. To use the external trigger pulse output mode, one-shot pulse mode, or pulse width measurement mode, select a count clock by clearing the TAAnEEE bit of the TAAnCTL1 register to 0. 2. When the external event count function is used, set the edge detection of the TIAAn0 capture input to "No edge detection" (TAAnIS1 and TAAnIS0 bits of TAAnIOC1 register to "00"). 326 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 10.6.1 Anytime write and reload TAAnCCR0 and TAAnCCR1 register rewrite is possible for timer AA during timer operation (TAAnCE = 1), but the write method (any time write, reload) differs depending on the mode. (1) Anytime write When data is written to the TAAnCCRm register during timer operation, it is transferred at any time to CCRm buffer register and used as the 16-bit counter comparison value. START Initial settings Timer operation enable (TAAnCE=1). Transfer of TAAnCCR0, TAAnCCR1 values to CCR0 and CCR1 buffer registers Rewrite TAAnCCR0. Transfer to CCR0 buffer register Rewrite TAAnCCR1. Transfer to CCR1 buffer register * Match between CCR0 buffer register and 16-bit counter * 16-bit counter clear and start Figure 10-4 Note INTTAAnCC0 output Flowchart of basic operation for anytime write 1. The above flowchart illustrates an example of the operation in the interval timer mode. 2. m = 0, 1 User's Manual U18743EE1V2UM00 327 Chapter 10 16-Bit Timer/Event Counter AA TAAnCE = 1 D01 D01 D02 16-bit counter TAAnCCR0 CCR0 buffer 0000H register TAAnCCR1 CCR1 buffer 0000H register D11 D11 D12 D12 D01 D02 D01 D02 D11 D12 D11 D12 INTTAAnCC0 INTTAAnCC1 Figure 10-5 Timing diagram for anytime write D01, D02: Setting values of TAAnCCR0 register (0000H to FFFFH) D11, D12: Setting values of TAAnCCR1 register (0000H to FFFFH) The above timing chart illustrates an example of the operation in the interval timer mode. 328 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (2) Chapter 10 Reload When data is written to the TAAnCCR0 and TAAnCCR1 registers during timer operation, it is compared with the value of the 16-bit counter via the CCRm buffer register. The values of the TAAnCCR0 and TAAnCCR1 registers can be rewritten when TAAnCE = 1. So that the set values of the TAAnCCR0 and TAAnCCR1 registers are compared with the value of the 16-bit counter (the set values are reloaded to the CCRm buffer register), the value of the TAAnCCR0 register must be rewritten and then a value must be written to the TAAnCCR1 register before the value of the 16-bit counter matches the value of TAAnCCR0. When the value of the TAAnCCR0 register matches the value of the 16-bit counter, the values of the TAAnCCR0 and TAAnCCR1 registers are reloaded. Whether the next reload timing is made valid or not is controlled by writing to the TAAnCCR1 register. Therefore, write the same value to the TAAnCCR1 register when it is necessary to rewrite the value of only the TAAnCCR0 register. START Initial setting Enable timer operation (TAAnCE=1) Transfer value of TAAnCCRm to CCRm buffer register Rewrite TAAnCCR0. Figure 10-6 Caution Rewrite TAAnCCR1. Reload is enabled * TAAnCCR0 matches 16-bit counter. * Clear and start 16-bit counter. * Value of TAAnCCRm is reloaded to CCRm buffer register. INTTAAnCC0 output Flowchart of basic operation for reload Writing to the TAAnCCR1 register includes an operation to enable reload. Therefore, rewrite the TAAnCCR1 register after rewriting the TAAnCCR0 register. User's Manual U18743EE1V2UM00 329 Chapter 10 16-Bit Timer/Event Counter AA Note 1. Above flowchart illustrates an example of the PWM mode operation. 2. m = 0, 1 TAAnCE = 1 D01 D02 D11 D12 16-bit counter D01 TAAnCCR0 CCR0 buff er 0000H register TAAnCCR1 D12 D12 D03 D01 D11 CCR1 buff er 0000H register D12 D02 D03 D02 D02 Note D03 Same value write D12 D11 D12 Note D12 D12 INTTAAnCC0 INTTAAnCC1 Figure 10-7 Note Timing chart for reload Reload is not performed because TAAnCCR1 register is not written. D01, D02, D03: Setting value of TAAnCCR0 register (0000H to FFFFH) D11, D12: Setting value of TAAnCCR1 register (0000H to FFFFH) Above flowchart illustrates PWM mode operation. 330 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 10.6.2 Interval timer mode (TAAnMD2 to TAAnMD0 = 000B) In the interval timer mode, an interrupt request signal (INTTAAnCC0) is generated upon a match between the setting value of the TAAnCCR0 register and the value of the 16-bit counter, and the 16-bit counter is cleared. The TAAnCCR0 register can be rewritten when TAAnCE = 1, and when a value is set to TAAnCCR0 with a write instruction from the CPU, it is transferred to the CCR0 buffer register through any time write mode, and is compared with the 16-bit counter value. In the interval timer mode, the 16-bit counter is cleared only upon a match between the value of the 16-bit counter and the value of the CCR0 buffer register. 16-bit counter clearing using the TAAnCCR1 register is not performed. However, the setting value of the TAAnCCR1 register is transferred to the CCR1 buffer register and compared with the value of the 16-bit counter, and an interrupt request (INTTAAnCC1) is output if these values match. In addition, TOAA1n pin output is also possible by setting the TAAnOE1 bit to 1. When the TAAnCCR1 register is not used, it is recommended to set FFFFH as the setting value for the TAAnCCR1 register. When performing timer output with the TOAAn1 pin, set the same values to the TAAnCCR0 register and the TAAnCCR1 register since the 16-bit timer counter cannot be cleared with the TAAnCCR1 register. STAR T Initial settings * Clock selection (TAAnCTL0: TAAnCKS[2:0]) * Interval mode setting (TAAnCTL1: TAAnMD[2:0] = 000B) * Compare register setting (TAAnOPT0: TAAnCCS[1:0]= 00) Timer operation enable (TAAnCE = 1) Transfer of TAAnCCR0, TAAnCCR1 values to CCR0 buffer register and CCR1 buffer register Figure 10-8 Match between 16-bit counter and CCR1 buffer register Note INTTAAnCC1 output Match between 16-bit counter and CCR0 buffer register, 16-bit counter clear & start INTTAAnCC0 output Flowchart of basic operation in interval timer mode User's Manual U18743EE1V2UM00 331 Chapter 10 16-Bit Timer/Event Counter AA Note The 16-bit counter is not cleared when its value matches the value of TAAnCCR1. TAAnCE = 1 FFFFH D1 D1 D2 D3 16-bit counterNote TAAnCCR0 CCR0 buffer register D1 0000H D2 D1 TAAnCCR1 CCR1 buffer register D3 D3 D2 D3 D3 0000H INTTAAnCC0 INTTAAnCC1 TOAAn0 TOAAn1 L H tD1 Figure 10-9 Note tD1 tD2 Basic operation timing in interval timer mode when D1 > D2 > D3; only TAAnCCR0 register value is written, and TOAAn0 and TOAAn1 are not output (TAAnOE0 = 0, TAAnOE1 = 0, TAAnOL0 = 0, TAAnOL1 = 1) The 16-bit counter is not cleared when its value matches the value of TAAnCCR1. D1, D2: Setting values of TAAnCCR0 register (0000H to FFFFH) D3: Setting value of TAAnCCR1 register (0000H to FFFFH) Interval time (tDn)= (Dn + 1) x (count clock cycle) 332 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 TAAnCE = 1 FFFFH D1 = D2 D1 = D 2 D1 = D 2 16-bit counter TAAnCCR0 CCR0 buffer register D1 D1 0000H TAAnCCR1 CCR1 buffer register D2 D2 0000H INTTAAnCC0 INTTAAnCC1 TOAAn0 TOAAn1 tD1 = tD2 Figure 10-10 tD1 = tD2 tD1 = tD2 Basic operation timing in interval timer mode when D1 = D2; TAAnCCR0 and TAAnCCR1 are not rewritten, and TOAAn0 and TOAAn1 are output (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 1) D1: Setting value of TAAnCCR0 register (0000H to FFFFH) D2: Setting value of TAAnCCR1 register (0000H to FFFFH) Interval time (tDn) = (Dn + 1) x (count clock cycle) User's Manual U18743EE1V2UM00 333 Chapter 10 16-Bit Timer/Event Counter AA When a new value is written to the TAAnCCR0 register that is smaller than the TAAn counter value at that moment, the counter will run to up to FFFFH and restart counting at 0000H. When the value of the counter then matches the TAAnCCR0 register a compare event will occur.. FFFFH D1 16-bit counter D1 D2 TAAnCE bit TAAnCCR0 D2 D2 Rewrite of TAAnCCR0 register D1 D2 INTTAAnCC0 Figure 10-11 334 Rewriting of the compare register with a smaller value than the current counter value User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 10.6.3 External event counter mode (TAAnMD2 to TAAnMD0 = 001B) In the external event count mode, the external event count input (TIAAn0 pin input) is used as a count-up signal. Regardless of the setting of the TAAnEEE bit of the TAAnCTL0 register, 16-bit timer/event counter AA counts up the external event count input (TIAAn0 pin input) when it is set in the external event count mode. In the external event count mode, an interrupt request (INTTAAnCC0) is generated when the set value of the TAAnCCR0 register matches the value of the 16-bit counter, and the value of the 16-bit counter is cleared. When a value is set to the TAAnCCR0 register with a write instruction from the CPU, it is transferred to the CCR0 buffer register through any time write, and is compared with the 16-bit counter value. In the external event counter mode, the 16-bit counter is cleared only upon a match between the value of the 16-bit counter and the value of the CCR0 buffer register. The 16-bit counter can not be cleared using TAAnCCR1 register. However, the setting value of the TAAnCCR1 register is transferred to the CCR1 buffer register and compared with the value of the 16-bit counter, and an interrupt request (INTTAAnCC1) is output if these values match. Moreover, TOAAnm pin output is also possible by setting the TAAnOEm bit to 1. When performing timer output with the TOAAn1 pin, set the same values to TAAnCCR0 register and TAAnCCR1 register since the 16-bit counter cannot be cleared with CCR1 buffer register. The TAAnCCR0 register can be rewritten when TAAnCE = 1. When TAAnCCR1 register is not used, it is recommended to set TAAnCCR1 register to FFFFH. User's Manual U18743EE1V2UM00 335 Chapter 10 16-Bit Timer/Event Counter AA START Initial setting * Clock selection (TAAnCTL0: TAAnCKS[2:0]) * Set external event count mode (TAAnCTL1: TAAnMD[2:0] = 001B)Note 1 * Set valid edge (TAAnIOC2: TAAnEES[1:0]) * Compare register setting (TAAnCCR0 and TAAnCCR1) (TAAnOPT0: TAAnCCS[1:0]=00) Timer operation enable (TAAnCE = 1) Transfer of TAAnCCR0, TAAnCCR1 values to CCR0 buffer register and CCR1 buffer register Figure 10-12 Note 16-bit counter matches CCR1 buffer register Note 2 INTTAAnCC1 output 16-bit counter matches CCR0 buffer register. Clear and start 16-bit counter INTTAAnCC0 output Flowchart of basic operation in external event counter mode 1. Selection of the TAAnEEE bit has no influence. 2. The 16-bit counter is not cleared upon a match between the 16-bit counter and the CCR1 buffer register. 3. m = 0, 1 336 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 TAAnCE = 1 FFFFH D1 D1 D2 D3 16-bit counter TAAnCCR0 D3 D3 D1 CCR0 buff er 0000H register D2 D1 TAAnCCR1 D2 D3 CCR1 buff er register 0000H D3 INTTAAnCC0 INTTAAnCC1 TOAAn1 H Figure 10-13 Basic Operation Timing in External Event Counter Mode When D1 > D2 > D3; rewrite TAAnCCR0 only; TOAAn1 is not output (TAAnOE0 = 0, TAAnOE1 = 0, TAAnOL0 = 0, TAAnOL1 = 1) D1, D2: Setting values of TAAnCCR0 register (0000H to FFFFH) D3: Setting value of TAAnCCR1 register (0000H to FFFFH) Number of event counts = (Dn + 1) User's Manual U18743EE1V2UM00 337 Chapter 10 16-Bit Timer/Event Counter AA TAAnCE = 1 FFFFH D 1 = D2 D1 = D2 D1 = D2 16-bit counter TAAnCCR0 CCR0 buff er register D1 D1 0000H TAAnCCR1 CCR1 buff er register D2 D2 0000H INTTAAnCC0 INTTAAnCC1 TOAAn1 Figure 10-14 Basic Operation Timing in External Event Counter Mode When D1 = D2; TAAnCCR0 and TAAnCCR1 are not rewritten, TOAAn1 is output (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 1) D1: Setting value of TAAnCCR0 register (0000H to FFFFH) D2: Setting value of TAAnCCR1 register (0000H to FFFFH) Number of event count = (Dn + 1) 338 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 10.6.4 External trigger pulse mode (TAAnMD2 to TAAnMD0 = 010B) When TAAnCE = 1 in the external trigger pulse mode, the 16-bit counter stops at FFFFH and waits for a trigger condition (input of an external trigger (TIAAn0 pin input) or SW trigger by setting of TAAnEST bit)). When the counter detects the trigger condition. The duty factor of the signal output from the TOAAn1 pin is set by a reload register (TAAnCCR1) and the period is set by a compare register (TAAnCCR0). Rewriting the TAAnCCR0 and TAAnCCR1 registers is enabled when TAAnCE = 1. To ensure that the selected values of the TAAnCCR0 and TAAnCCR1 registers after rewriting are compared with the value of the 16-bit counter (reloaded to the CCRm buffer register), the TAAnCCR0 register and then the TAAnCCR1 register must be written before the value of the 16-bit counter matches the value of the TAAnCCR0 register. When the value of the TAAnCCR0 register later matches the value of the 16-bit counter, the values of the TAAnCCR0 and TAAnCCR1 registers are reloaded to the CCRm buffer register. Whether the next reload timing is made valid or not is controlled by writing to the TAAnCCR1 register. Therefore, write the same value to the TAAnCCR1 register when it is necessary to rewrite the value of only the TAAnCCR0 register. Reload is invalid when only the TAAnCCR0 register is rewritten. To stop timer AA, clear TAAnCE to 0. If the edge of the external trigger (TIAAn0 pin input) is detected more than once in the external trigger pulse mode, the 16-bit counter is cleared at the point of edge detection, and resumes counting up. To realize the same function as the external trigger pulse mode by using a software trigger instead of the external trigger input (TIAAn0 pin input) (software trigger pulse mode), a software trigger is generated by setting the TAAnEST bit of the TAAnCTL1 register to 1. When using a software trigger, a square wave that has one cycle of the PWM waveform as half of its own cycle can also be outputed from the TOAAn0 pin. The waveform of the external trigger pulse is output from TOAAn1. A toggle output is produced from the TOAAn0 pin when the value of the TAAnCCR0 register matches the value of the 16-bit counter. In the external trigger pulse mode, the capture function of the TAAnCCR0 and TAAnCCR1 registers cannot be used because these registers can be used only as compare registers. Caution In the external trigger pulse mode, select the internal clock (TAAnEEE bit of TAAnCTL1 register = 0) for the count clock. Note 1. For the reload operation when TAAnCCR0 and TAAnCCR1 are rewritten during timer operation, refer to "PWM mode (TAAnMD2 to TAAnMD0 = 100B)" on page 345. 2. m = 0, 1 User's Manual U18743EE1V2UM00 339 Chapter 10 16-Bit Timer/Event Counter AA START * Clock selection (TAAnCTL0: TAAnCKS[2:0], Initial settings TAAnCTL1: TAAnEEE=0) * External trigger pulse output mode Note 1 setting (TAAnCTL1: TAAnMD[2:0] = 010B) * Compare register setting (TAAnCCR0, TAA,CCR1) (TAAnOPT0: TAAnCCS[1:0] = 00) Timer operation enable (TAAnCE = 1) Transfer of TAAnCCR0, TAAnCCR1 values to CCR0 buffer register and CCR1 buffer register External trigger (TIAAn0 pin) input, or TAAnEST = 1 16-bit counter start Note Figure 10-15 Note 340 External trigger pin input (TIAAn0) 16-bit counter clear & start Match between 16-bit counter and CCR1 buffer register Note 1 INTTAAnCC1 output Match between 16-bit counter and CCR0 buffer register, 16-bit counter clear & start INTTAAnCC0 output Flowchart of Basic Operation in External Trigger Pulse Output Mode The 16-bit counter is not cleared upon a match between the 16-bit counter and the CCR1 buffer register. User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 TAAnCE = 1 FFFFH D02 D01 16-bit counterNote D12 D11 D11 External trigger (TIAAn0 pin) D01 TAAnCCR0 CCR0 buffer register 0000H D01 D11 TAAnCCR1 CCR1 buffer register D02 0000H D02 D12 D11 D12 TOAAn1 TOAAn0 Figure 10-16 Note Basic Operation Timing in External Trigger Pulse Output Mode (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 0) The 16-bit counter is not cleared when it matches the CCR1 buffer register. D01, D02: Setting value of TAAnCCR0 register (0000H to FFFFH) D11, D12: Setting value of TAAnCCR1 register (0000H to FFFFH) Duty of TOAAn1 output = (Set value of TAAnCCR1 register) / (Set value of TAA0CCR0 register) Cycle of TOAAn1 output = (Set value of TAAnCCR0 register + 1) (Count clock cycle) User's Manual U18743EE1V2UM00 341 Chapter 10 16-Bit Timer/Event Counter AA 10.6.5 One-shot pulse mode (TAAnMD2 to TAAnMD0 = 011B) When TAAnCE is set to 1 in the one-shot pulse mode, the 16-bit counter waits for the setting of the TAAnEST bit (to 1) or a trigger that is input when the edge of the TIAAn0 pin is detected, while holding FFFFH. When the trigger is input, the 16-bit counter starts counting up. When the value of the 16-bit counter matches the value of the CCR1 buffer register that has been transferred from the TAAnCCR1 register, TOAAn1 goes high. When the value of the 16-bit counter matches the value of the CCR0 buffer register that has been transferred from the TAAnCCR0 register, TOAAn1 goes low, and the 16-bit counter is cleared to 0000H and stops. Input of a second or subsequent trigger is ignored while the 16-bit counter is operating. Be sure to input a second trigger while the 16-bit counter is stopped at 0000H. In the one shot pulse mode, rewriting the TAAnCCR0 and TAAnCCR1 registers is enabled when TAAnCE = 1. The set values of the TAAnCCR0 and TAAnCCR1 registers become valid after a write instruction from the CPU is executed. They are then transferred to the CCR0 and CCR1 buffer registers, and compared with the value of the 16-bit counter. The waveform of the oneshot pulse is output from the TOAAn1 pin. The TOAAn0 pin produces a toggle output when the value of the 16-bit counter matches the value of the TAAnCCR0 register. In the one-shot pulse mode, the TAAnCCR0 and TAAnCCR1 registers function only as compare registers. They cannot be used as capture registers. Caution 1. In the one-shot pulse mode, select the internal clock (TAAnEEE bit of TAAnCTL1 register = 0) as the count clock. 2. In the one-shot pulse mode, it is prohibited to set the TAAnCCR1 register to 0000H. 342 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 STAR T Initial settings * Clock selection (TAAnCTL1: TAAnEEE = 0) (TAAnCTL0: TAAnCKS[2:0]) * One-shot pulse mode setting (TAAnCTL1: TAAnMD[2:0]=011) * Compare register setting (TAAnCCR0, TAAnCCR1) Timer operation enable (TAAnCE = 1) Transfer of TAAnCCR0, TAAnCCR1 values to CCR0 buffer register and CCR1 buffer register Trigger wait status, 16-bit counter in standby at FFFFH External trigger (TIAAn0 pin) input, or TAAnEST = 1 Note 1 16-bit counter start Trigger wait status, 16-bit counter in standby at 0000H Figure 10-17 Note Match between 16-bit counter and CCR1 buffer register Note 2 INTTAAnCC1 output Match between 16-bit counter and CCR0 buffer register, 16-bit counter clear & start INTTAAnCC0 output Flowchart of Basic Operation in One-Shot Pulse Mode 1. Only the TAAnEST bit of the TAAnCTL1 register can be rewritten during the timer operation (TAAnCE = 1). 2. The 16-bit counter is not cleared upon a match between the values of the 16-bit counter and the CCR1 buffer register. Caution The 16-bit counter is not cleared when a trigger input is performed during the count-up operation of the 16-bit counter. User's Manual U18743EE1V2UM00 343 Chapter 10 16-Bit Timer/Event Counter AA TAAnCE = 1 TAAnEST = 1 FFFFH 16-bit counter D0 D0 Note D1 D1 D0 D1 External trigger (TIAAn0 pin) TAAnCCR0 CCR0 buffer register D0 0000H D0 TAAnCCR1 CC1 buffer register D1 0000H D1 INTTAAnCC0 INTTAAnCC1 TOAAn1 TOAAn0 Figure 10-18 Note Timing of Basic Operation in One-Shot Pulse Mode (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 0) The 16-bit counter starts counting up when either TAAnEST = 1 is set or the external trigger (TIAAn0) is input. D0: Setting value of TAAnCCR0 register (0000H to FFFFH) D1: Setting value of TAAnCCR1 register (0000H to FFFFH) Active level period of TOAAn1 pin output is (setting value of TAAnCCR0 setting value of TAAnCCR1 + 1) x count clock period Output delay period = (setting value of TAAnCCR 1 register) x count clock period 344 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 10.6.6 PWM mode (TAAnMD2 to TAAnMD0 = 100B) In the PWM mode, TAAn capture/compare register 1 (TAAnCCR1) is used to set the duty factor and TAAn capture/compare register 0 (TAAnCCR0) is used to set the cycle. By using these two registers and operating the timer, variableduty PWM is output. Rewriting the TAAnCCR0 and TAAnCCR1 registers is enabled when TAAnCE = 1. So that the set values of the TAAnCCR0 and TAAnCCR1 registers are compared with the value of the 16-bit counter (reloaded to the CCR0 and CCR1 buffer registers), the TAAnCCR0 register must be rewritten and then a value must be written to the TAAnCCR1 register before the value of the 16-bit counter matches the value of the TAAnCCR0 register. The values of the TAAnCCR0 and TAAnCCR1 registers are reloaded when the value of the TAAnCCR0 register later matches the value of the 16-bit counter. Whether the next reload timing is made valid or not is controlled by writing to the TAAnCCR1 register. Therefore, write the same value to the TAAnCCR1 register even when only the value of the TAAnCCR0 register needs to be rewritten. Reload is invalid when only the value of the TAAnCCR0 register is rewritten. To stop timer AA, clear TAAnCE to 0. The waveform of PWM is output from the TOAAn1 pin. The TOAAn0 pin produces a toggle output when the 16-bit counter matches the TAAnCCR0 register. In the PWM mode, the TAAnCCR0 and TAAnCCR1 registers are used only as compare registers. They cannot be used as capture registers. User's Manual U18743EE1V2UM00 345 Chapter 10 16-Bit Timer/Event Counter AA START Initial setting * Select clock. (TAAnCTL0: TAAnCKS[2:0]) * Set PWM mode. (TAAnCTL1: TAAnMD[2:0] = 100B) * Set compare register. (TAAnCCR0, TAAnCCR1) Enable timer operation (TAAnCE = 1) Transfer value of TAAnCCRm register to CCRm buffer register 16-bit counter matches TAAnCCR1. TOAAn1 outputs inactive level. 16-bit counter matches TAAnCCR0. Clear and start 16-bit counter. TOAAn1 outputs active level. Figure 10-19 346 INTTAAnCC1 output INTTAAnCC0 output Flowchart of Basic Operation in PWM Mode When values of TAAnCCR0, TAAnCCR1 registers are not rewritten during timer operation User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 START Initial setting * Select clock. (TAAnCTL0: TAAnCKS[2:0]) * Set PWM mode. (TAAnCTL1: TAAnMD[2:0] = 100B) * Set compare register. (TAAnCCR0, TAAnCCR1) Enable timer operation (TAAnCE = 1) Transfer value of TAAnCCRm register to CCRm buffer register 16-bit counter matches TAAnCCR1. TOAAn1 outputs inactive level. INTTAAnCC1 output 16-bit counter matches TAAnCCR0. Clear and start 16-bit counter. TOAAn1 outputs active level. Rewrite TAAnCCR0. <1> 16-bit counter matches CCR1 buffer register. TOAAn1 outputs inactive level. <2> Rewrite TAAnCCR1. <3> * CCR0 buffer register matches 16-bit counter. * Clear and start 16-bit counter. * Value of TAAnCCRm is reloaded to CCRm buffer register. Figure 10-20 Note INTTAAnCC0 output INTTAAnCC1 output Note 1 Reload is enabled INTTAAnCC0 output Flowchart of Basic Operation in PWM Mode When values of TAAnCCR0, TAAnCCR1 registers are rewritten during timer operation 1. The timing of <2> in the above flowchart may differ depending on the rewrite timing of steps <1> and <3> and the value of TAAnCCR1, but make sure that step <3> comes after step <1>. 2. m = 0, 1 User's Manual U18743EE1V2UM00 347 Chapter 10 16-Bit Timer/Event Counter AA TAAnCE = 1 FFFFH D00 D00 D00 D00 D11 16-bit counter D10 D10 D12 D00 TAAnCCR0 CCR0 buffer register 0000H TAAnCCR1 CCR1 buffer register D00 D10 0000H D11 D10 D12 D11 D13 D12 D13 TOAAn1 TOAAn0 Figure 10-21 Basic Operation Timing in PWM Mode When rewriting TAAnCCR1 value (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 0) D00: Set value of TAAnCCR0 register (0000H to FFFFH) D10, D11, D12, D13: Set value of TAAnCCR1 register (0000H to FFFFH) Duty of TOAAn1 output = (Set value of TAAnCCR1 register) / (Set value of TAAnCCR0 register + 1) Cycle of TOAAn1 output = (Set value of TAAnCCR0 register + 1) x (Count clock cycle) Toggle width of TOAAn0 output = (Set value of TAAnCCR0 register + 1) x (Count clock period) 348 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 TAAnCE = 1 FFFFH D00 D01 D01 D02 16-bit counter D11 D12 D10 D00 TAAnCCR0 CCR0 buffer register D11 0000H D01 D02 D03 Note D01 D00 D02 D03 Same value write TAAnCCR1 CCR1 buffer register D10 0000H D10 D11 D12 D11 D12 D12 D12 TOAAn1 TOAAn0 Figure 10-22 Note Basic Operation Timing in PWM Mode When TAAnCCR0, TAAnCCR1 values are rewritten (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 0) Reload is not performed because the TAAnCCR1 register was not rewritten. D00, D01, D02, D03: Setting values of TAAnCCR0 register (0000H to FFFFH) D10, D11, D12, D13: Setting values of TAAnCCR1 register (0000H to FFFFH) Duty of TOAAn1 output = (Set value of TAAnCCR1 register) / (Set value of TAAnCCR0 register + 1) Cycle of TOAAn1 output = (Set value of TAAnCCR0 register + 1) x (Count clock cycle) Toggle width of TOAAn0 output = (Set value of TAAnCCR0 register + 1) x (Count clock cycle) Note To output a 0% duty PWM signal set the TAAnCCR1 register to 0. To output a 100% duty PWM signal set the TAAnCCR1 register to the value of the CCR0 register +1. Do not set a value of FFFFH to the CCR1 register. User's Manual U18743EE1V2UM00 349 Chapter 10 16-Bit Timer/Event Counter AA 10.6.7 Free-running mode (TAAnMD2 to TAAnMD0 = 101B) In the free-running mode, both the interval function and the compare function can be realized by operating the 16-bit counter as a free-running counter and selecting capture/compare operation with the TAAnCCS1 and TAAnCCS0 bits. The settings of the TAAnCCS1 and TAAnCCS0 bits of the TAAnOPT0 register are valid only in the free-running mode. TAAnCCS1 Operation 0 Use TAAnCCR1 register as compare register 1 Use TAAnCCR1 register as capture register TAAnCCS0 Operation 0 Use TAAnCCR0 register as compare register 1 Use TAAnCCR0 register as capture register * Using TAAnCCR1 register as compare register An interrupt is output upon a match between the 16-bit counter and the CCR1 buffer register in the free-running mode. Rewrite during compare timer operation is enabled and performed with any time write mode. (Once the compare value has been written, synchronization with the internal clock is done and this value is used as the 16-bit counter comparison value.) When timer output (TOAAn1) has been enabled, TOAAn1 performs toggle output upon a match between the 16-bit counter and the CCR1 buffer register. * Using TAAnCCR1 register as capture register The value of the 16-bit counter is saved to the TAAnCCR1 register upon TIAAn1 pin edge detection. * Using TAAnCCR0 register as compare register An interrupt is output upon a match between the 16-bit counter and the CCR0 buffer register in the free-running mode. Rewrite during compare timer operation is enabled and performed with any time write mode. (Once the compare value has been written, synchronization with the internal clock is done and this value is used as the 16-bit counter comparison value.) When timer output (TOAAn0) has been enabled, TOAAn0 performs toggle output upon a match between the 16-bit counter and the CCR0 buffer register. * Using TAAnCCR0 register as capture register The value of the 16-bit counter is saved to the TAAnCCR0 register upon TIAAn0 pin edge detection. Caution 350 When the TAAnEEE bit of AAnCTL1 register is set to 1 and the count clock is set to the external event count input, the TAAnCCR0 register cannot be used as the capture register. User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 START Initial settings * Clock selection (TAAnCTL0: TAAnCKS[2:0]) * Free-running mode setting (TAAnCTL1: TAAnMD[2:0] = 101B) TAAnCCS[1:0] setting TAAnCCS[1:0] = 00 Timer operation enable (TAAnCE = 1) TAAnCCS[1:0] = 01 TIAAn0 edge detection setting (TAAnIS1, TAAnIS0) TAAnCCS[1:0] = 11 TAAnCCS[1:0] = 10 TIAAn1 edge detection setting (TAAnIS3, TAAnIS2) TIAAn0, TIAAn1 edge det. setting (TAAnIS[3:0]) Transfer of TAAnCCR0 and TAAnCCR1 values to CCR0 and CCR1 buffer registers Timer operation enable (TAAnCE = 1) Transfer of TAAnCCR1 value to CCR1 buffer register Match between CCR1 buffer and 16-bit counter Match between CCR0 buffer and 16-bit counter Timer operation enable (TAAnCE = 1) Timer operation enable (TAAnCE = 1) Transfer of TAAnCCR0 value to CCR0 buffer register TIAAn1 edge detection, capture of 16-bit counter value to TAAnCCR1. Match between CCR1 buffer and 16-bit counter TIAAn0 edge detection, capture of 16-bit counter value to TAAnCCR0. TIAAn1 edge detection, capture of 16-bit counter value to TAAnCCR1. Match between CCR0 buffer and 16-bit counter TIAAn0 edge detection, capture of 16-bit counter value to TAAnCCR0. 16-bit counter overflow 16-bit counter overflow 16-bit counter overflow Figure 10-23 16-bit counter overflow Flowchart of Basic Operation in Free-Running Mode User's Manual U18743EE1V2UM00 351 Chapter 10 16-Bit Timer/Event Counter AA (1) When TAAnCCS1 = 0, and TAAnCCS0 = 0 settings (interval function description, compare function) When TAAnCE = 1 is set, the 16-bit counter counts from 0000H to FFFFH and the free-running count-up operation continues until TAAnCE = 0 is set. In this mode, when a value is written to the TAAnCCR0 and TAAnCCR1 registers, they are transferred to the CCR0 buffer register and the CCR1 buffer register (any time write mode). In this mode, no one-shot pulse is output even when an one-shot pulse trigger is input. Moreover, when TAAnOEm = 1 is set, TOAAnm performs toggle output upon a match between the 16-bit counter and the CCRm buffer register. TAAnCE = 1 FFFFH D01 D11 16-bit counter D00 D11 D00 D10 TAAnCCR0 CCR0 buffer register D00 0000H D01 D01 D00 INTTAAnCC0 match interrupt TAAnCCR1 CCR1 buffer register 0000H D10 D11 D10 D11 INTTAAnCC1 match interrupt TOAAn0 TOAAn1 INTTAAnOV TAAnOVF Clear by writing 0 to TAAnOVF Figure 10-24 Clear by writing 0 to TAAnOVF Basic Operation Timing in Free-Running Mode (TAAnCCS1 = 0, TAAnCCS0 = 0) (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 0) D00, D01: Setting values of TAAnCCR0 register (0000H to FFFFH) D10, D11: Setting values of TAAnCCR1 register (0000H to FFFFH) TOAAn0 output toggle width = (Setting values of TAAnCCR0 register) x (count clock cycle) TOAAn1 output toggle width = (Setting values of TAAnCCR1 register) TOAAnm output goes high when counting is started. Note 352 m = 0, 1 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (2) Chapter 10 When TAAnCCS1 = 1 and TAAnCCS0 = 1 settings (capture function description) When TAAnCE = 1, the 16-bit counter counts from 0000H to FFFFH and freerunning count-up operation continues until TAAnCE = 0 is set. During this time, values are captured by capture trigger operation and are written to the TAAnCCR0 and TAAnCCR1 registers. Regarding capture close to the overflow (FFFFH), judgment is made using the overflow flag (TAAnOVF). However, if overflow occurs twice (two or more freerunning cycles), the capture trigger interval cannot be judged with the TAAnOVF flag. In this case, the system should be revised. TAAnCE = 1 FFFFH D10 D02 D12 16-bit counter D00 D01 D11 D03 TIAAn0 TAAnCCR0 0000H D00 D01 D02 D03 TIAAn1 0000H TAAnCCR1 D10 D11 D12 INTTAAnCC0 capture interrupt INTTAAnCC1 capture interrupt INTTAAnOV TOAAn0 L TOAAn1 L Figure 10-25 Basic Operation Timing in Free-Running Mode (TAAnCCS1 = 1, TAAnCCS0 = 1) (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 0) D00, D01, D02, D03: Values captured to TAAnCCR0 register (0000H to FFFFH) D10, D11, D12: Values captured to TAAnCCR1 register (0000H to FFFFH) TIAAn0: Set to rising edge detection (TAAnIS1, TAAnIS0 = 01) TIAAn1: Set to falling edge detection (TAAnIS3, TAAnIS2 = 10) User's Manual U18743EE1V2UM00 353 Chapter 10 16-Bit Timer/Event Counter AA (3) When TAAnCCS1 = 1 and TAAnCCS0 = 0 When TAAnCE = 1 is set, the counter counts from 0000H to FFFFH and freerunning count-up operation continues until TAAnCE = 0 is set. The TAAnCCR0 register is used as a compare register. An interrupt signal is output upon a match between the value of the 16-bit counter and the setting value transferred to the CCR0 buffer register from the TAAnCCR0 register as an interval function. Even if TAAnOE1 = 1 to realize the output function, TAAnCCR1 register cannot control TOAAn1 because it is used as capture register. TAAnCE=1 FFFFH D01 D11 15 D14D D10 D00 16-bit counter D00 D13 D12 D00 TAAnCCR0 CCR0 buffer register D01 D00 0000H D01 INTTAAnCC0 mactch interrupt TIAAn1 TAAnCCR1 0000H D10 D11 D12 D13 D15 D14 Figure 10-26 Basic Operation Timing in Free-Running Mode (TAAnCCS1 = 1, TAAnCCS0 = 0) (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 0) D00, D01: Setting compare values of TAAnCCR0 register (0000H to FFFFH) D10, D11, D12, D13, D14, D15: Values captured to TAAnCCR1 register (0000H to FFFFH) TIAAn1: Set to detection of both rising and falling edges (TAAnIS3, TAAnIS2 = 11) 354 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (4) Chapter 10 When TAAnCCS1 = 0 and TAAnCS0 = 1 When TAAnCE is set to 1, the 16-bit counter counts from 0000H to FFFFH and free-running count-up operation continues until TAAnCE = 0 is set. The TAAnCCR1 register is used as a compare register. An interrupt signal is output upon a match between the value of the 16-bit counter and the setting value of the TAAnCCR1 register as an interval function. When TAAnOE1 = 1 is set, TOAAn1 performs toggle output upon mach between the value of the 16-bit counter and the setting value of the TAAnCCR1 register. Even if TAAnOE0 = 1 to realize the output function, TAAnCCR0 register cannot control TOAAn0 because it is used as capture register. TAAnCE = 1 FFFFH D02 D00 D03 D10 16-bit counter D12 D01 D11 D11 TIAAn0 TAAnCCR0 0000H D01 D00 D03 D02 INTTAAnCC0 capture interrupt D10 TAAnCCR1 CCR1 buffer register 0000H D10 D11 D12 D11 D12 INTTAAnCC1 match interrupt INTTAAnOV TOAAn0 L TOAAn1 Figure 10-27 Basic Operation Timing in Free-Running Mode (TAAnCCS1 = 0, TAAnCCS0 = 1) (TAAnOE0 = 1, TAAnOE1 = 1, TAAnOL0 = 0, TAAnOL1 = 0) D00, D01, D02, D03: Values captured to TAAnCCR0 register (0000H to FFFFH) D10, D11, D12: Setting compare value of TAAnCCR1 register (0000H to FFFFH) TIAAn0: Set to falling edge detection (TAAnIS1, TAAnIS0 = 10) (5) Overflow flag When the counter overflows from FFFFH to 0000H in the free-running mode, the overflow flag (TAAnOVF) is set to 1 and an overflow interrupt (INTTAAnOV) is output. The overflow flag is cleared by the CPU when writing 0 to it. User's Manual U18743EE1V2UM00 355 Chapter 10 16-Bit Timer/Event Counter AA 10.6.8 Pulse width measurement mode (TAAnMD2 to TAAnMD0 = 110B) In the pulse width measurement mode, free-running count is performed. The value of the 16-bit counter is saved to capture register 0 (TAAnCCR0), or capture register 1 (TAAnCCR1) respectively, and the 16-bit counter is cleared upon edge detection of the TIAAn0 pin, or TIAAn1 respectively. The external input pulse width can be measured as a result. However, when measuring a large pulse width that exceeds 16-bit counter overflow, perform judgment with the overflow flag, e.g by counting the overflow count by using the overflow interrupt. Depending on the selected capture input sources and specified edge detection three different measurement methods can be applied. 1. Pulse period measurement 2. Alternating pulse width and pulse space measurement. 3. Simultaneous pulse width and pulse space measurement: Both capture inputs are required to measure pulse width and pulse space simultaneously. The measurements methods are explained in the following sub-chapters. Caution 356 In the pulse width measurement mode, select the internal clock (TAAnEEE of TAAnCTL1 register = 0). User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (1) Chapter 10 Pulse period measurement The pulse period of a signal can be measured in the pulse width measurement mode, when the edge detection of one of the inputs TIAAn0 and TIAAn1 is set either to "rising edge" or "falling edge". The detection of the other input should be set to "no edge detection". By detection of the specified edge the resulting value is captured in the corresponding capture register (TAAnCCR0 or TAAnCCR1), and the timer is cleared and restarts counting. START Initial settings * Clock selection (TAAnCTL0: TAAnCKS2 to TAAnCKS0) * Pulse width measurement mode setting (TAAnCTL1: TAAnMD2 to TAAnMD0 = 110B) * Capture register setting (TAAnCCR0, TAAnCCR1) Note 1 TIAAn1/TIAAn0 edge detection setting (TAAnIS3 to TAAnIS0) Timer operation enable (TAAnCE = 1) Specified edge input to TIAAnm (rising or falling edge), capture of value to TAAnCCRm, 16-bit counter clear & start Figure 10-28 Note Flowchart of Pulse Period Measurement 1. External pulse input is possible for both TIAAn0 and TIAAn1, but only one should be selected for the pulse period measurement. Specify either "rising edge" or "falling edge" for edge detection. Specify the edge of the external input pulse that is not used as "no edge detection". 2. m = 0, 1 User's Manual U18743EE1V2UM00 357 Chapter 10 16-Bit Timer/Event Counter AA TAAnCE = 1 FFFFH D01 FFFFH D02 16-bit counter D00 TIAAn0 TAAnCC0 0000H D00 D01 D02 INTTAAnCCR0 cleared by writing 0 from CPU TAAnOVF INTTAAnOV Figure 10-29 Basic Operation Timing of Pulse Period Measurement (TAAnOE0 = 0, TAAnOE1 = 0, TAAnOL0 = 0, TAAnOL1 = 0) D00, D01, D02: Values captured to TAAnCCR0 register (0000H to FFFFH) TIAAn0: Set to detection of rising edge (TAAnIS1, TAAnIS0 = 01B) TIAAn1: Set to no edge detection (TAAnIS3, TAAnIS2 = 00B) 358 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (2) Chapter 10 Alternating pulse width and pulse space measurement The pulse period of a signal can be measured in the pulse width measurement mode alternating in one capture register, when the edge detection of one of the inputs TIAAn0 and TIAAn1 is set to "both rising and falling edges". The detection of the other input should be set to "no edge detection". By detection of a falling or rising edge the resulting value is captured in the corresponding capture register (TAAnCCR0 or TAAnCCR1), and the timer is cleared and restarts counting. START Initial settings * Clock selection (TAAnCTL0: TAAnCKS2 to TAAnCKS0) * Pulse width measurement mode setting (TAAnCTL1: TAAnMD2 to TAAnMD0 = 110B) * Capture register setting (TAAnCCR0, TAAnCCR1) TIAAn1/TIAAn0 edge detection setting Note 1 (TAAnIS3 to TAAnIS0) Timer operation enable (TAAnCE = 1) Rising edge input to TIAAnm, capture of value to TAAnCCRm, 16-bit counter clear & start Falling edge input to TIAAnm, capture of value to TAAnCCRm, 16-bit counter clear & start Figure 10-30 Note Flowchart of Alternating Pulse Width and Pulse Space Measurement 1. External pulse input is possible for both TIAAn0 and TIAAn1, but only one should be selected for the alternating pulse width and pulse space measurement. Specify "both rising and the falling edges" for edge detection. Specify the edge of the external input pulse that is not used as "no edge detection". 2. m = 0, 1 User's Manual U18743EE1V2UM00 359 Chapter 10 16-Bit Timer/Event Counter AA TAAnCE = 1 FFFFH FFFFH D01 16-bit counter D02 D00 D03 D04 TIAAn0 TAAnCCR0 0000H D00 D01 D02 D03 D04 INTTAAnCC0 cleared by writing 0 from CPU TAAnOVF INTTAAnOV Figure 10-31 Basic Operation Timing of Alternating Pulse Width and Pulse Space Measurement (TAAnOE0 = 0, TAAnOE1 = 0, TAAnOL0 = 0, TAAnOL1 = 0) D00, D01, D02, D03, D04: Values captured to TAAnCCR0 register (0000H to FFFFH) TIAAn0: Set to detection of both rising and falling edges (TAAnIS1, TAAnIS0 = 11B) TIAAn1: Set to no edge detection (TAAnIS3, TAAnIS2 = 00B) Pulse width = Captured value x Count clock cycle If the valid edge is not input even when the 16-bit counter counted up to FFFFH, an overflow interrupt request signal (NTTAAnOV) is generated at the next count clock, and the counter is cleared to 0000H and continues counting. At this time, the overflow flag (TAAnOPT0.TAAnOVF bit) is also set to 1. Clear the overflow flag to 0 by executing the CLR instruction via software. If the overflow flag is set to 1, the pulse width can be calculated as follows. Pulse width = (10000H x TAAnOVF bit set (1) count + Captured value) x Count clock cycle 360 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA (3) Chapter 10 Simultaneous pulse width and pulse space measurement Pulse width and pulse space can be measure simultaneously in the pulse width measurement mode, when the signal is input to both inputs TIAAn0 and TIAAn1, where both inputs detect opposite edges. By detection of the specified edge the resulting values of pulse width or pulse space are captured in the corresponding capture registers (TAAnCCR0, TAAnCCR1), and the timer is cleared and restarts counting. START Initial settings * Clock selection (TAAnCTL0: TAAnCKS2 to TAAnCKS0) * Pulse width measurement mode setting (TAAnCTL1: TAAnMD2 to TAAnMD0 = 110B) * Capture register setting (TAAnCCR0, TAAnCCR1) TIAAn1/TIAAn0 edge detection setting Note 1 (TAAnIS3 to TAAnIS0) Timer operation enable (TAAnCE = 1) Rising edge input to TIAAnx, capture of value to TAAnCCRx, 16-bit counter clear & start Falling edge input to TIAAny, capture of value to TAAnCCRy, 16-bit counter clear & start Figure 10-32 Note Flowchart of Simultaneous Pulse Width and Pulse Space Measurement 1. External pulse input must be input to both TIAAn0 and TIAAn1. Specify "rising edge" for edge detection of first input, and "falling edge" for the second input, or vice versa. 2. x = 0, 1 y = 0 when x = 1; y = 1 when x = 0 User's Manual U18743EE1V2UM00 361 Chapter 10 16-Bit Timer/Event Counter AA TAAnCE = 1 FFFFH FFFFH D10 16-bit counter D01 D00 D11 D02 Note TIAAn0, TIAAn1 TAAnCCR0 0000H TAAnCCR1 0000H D00 D01 D10 D02 D11 INTTAAnCC0 INTTAAnCC1 cleared by writing 0 from CPU TAAnOVF INTTAAnOV Figure 10-33 Note Basic Operation Timing of Simultaneous Pulse Width and Pulse Space Measurement (TAAnOE0 = 0, TAAnOE1 = 0, TAAnOL0 = 0, TAAnOL1 = 0) The signal to measure has to be assigned to both inputs, TIAAn0 and TIAAn1. D00, D01, D02: Values captured to TAAnCCR0 register (0000H to FFFFH) D10, D11: Values captured to TAAnCCR1 register (0000H to FFFFH) TIAAn0: Set detection to rising edge (TAAnIS1, TAAnIS0 = 01B) TIAAn1: Set detection to falling edge (TAAnIS3, TAAnIS2 = 10B) 362 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 10.6.9 32-bit Capture in Free-Running Cascade Mode Two Timer AA (TAA0 in combination with TAA1, or TAA2 in combination with TAA3) can be cascaded to operate as a 32-bit capture timer. In cascade mode, the timer with the lower number (TAA0 or TAA2) is used to control the operation (master timer). Both cascaded timers have to be initialized as freerunning timers. TAAmCTL0 TAAmIOC2 TAAmOPT1 TMAAm TAAmCSE=0 TAAmCCR0 TAAmCNT0 Load TAAmCE CCR1 buffer register Trigger control Edge detector Clear 16-bit counter Counter control Edge detector INTTAAmCC0 TAAmCE INTTAAmOV Selector Edge detector Input circuit (see separate figure) CCR0 buffer register Selector TAAmTRG0 Selector TAAmCE fXP1 or fXP2 fXP1/2 or fXP2/2 fXP1/4 or fXP2/4 fXP1/8 fXP1/16 fXP1/32 fXP1/64 fXP1/128 or fXT Load INTTAAmCC1 TAAmCCR1 Capture/compare selection function TAAmOV TAAmTRG1 Edge detector note 2 TOAAm0 Output controller TAAmIOC1 TAAmCTL1 TAAmIOC0 TAAmOPT0 TAAnOPT1 TOAAm1 TAAmIOC3 TMAAn TAAnCCR0 TAAnCSE=1 TAAnCNT0 CCR0 buffer register Selector TAAmTRG0 Load TAAmCE Counter control Clear 16-bit counter Trigger control CCR1 buffer register TAAnCE INTTAAnOV Selector INTTAAmOV INTTAAnCC0 Load INTTAAnCC1 TAAnCCR1 Capture/compare selection function TAAmTRG1 Output controller TAAnCTL1 Figure 10-34 TAAnOPT0 TAAnIOC0 TAAnIOC3 Block Diagram of TAAm and TAAn in 32-bit Capture Mode User's Manual U18743EE1V2UM00 363 Chapter 10 16-Bit Timer/Event Counter AA Note 1. m = 0, 2 n = 1, 3 2. The 32-bit capture in cascade free-running mode is not available for TAA4. 3. Explanation of signals can be found in Figure 10-1 on page 307. 4. Block diagrams of the input circuits can be found in Figure 10-2 on page 308 to Figure 10-3 on page 308, Figure 10-34 shows the block diagram of TAAm and TAAn in cascade mode. Signals that are irrelevant in cascade mode are not shown, the connections to the internal bus are also hidden for better readability of the image, as Figure 10-1 on page 307 can be used for a in-depth look of each timer. Note Cascading of two TAA is only allowed for free-running mode with both capture/ compare registers set to capture mode. Proper operation of TAAm and TAAn is not guaranteed for any other setting. Figure 10-35 shows the recommended flow for setting up TAAm and TAAn in cascade mode. As TAAm is used for general control, TAAn is set up first and set in cascaded operation by setting the TAAnCSE bit to 1. Then TAAm is initialized by selecting the proper clock setting and capture trigger input. Only TIAAm0 and TIAAm1 can be used as external capture trigger. Note When cascading TAAm and TAAn, set TAAnCSE=1 and TAAmCSE=0. Operation starts when the count enable flag of TAAm (TAAmCE) is set to 1. The counter of TAAm is used for the lower 16-bit of the 32-bit count value, while the upper 16-bit are handled by TAAn. Whenever the counter of TAAm overflows, the counter is cleared to 0, interrupt INTTAAmOV is generated and the counter of TAAn is incremented by 1. When the counter of TAAn overflows, the counter is also cleared to 0 and interrupt INTTAAnOV is generated. When a capture trigger 0/1 is detected by TAAm, a capture of the lower 16-bit counter value to TAAmCCR0/1 and of the upper 16-bit counter value to TAAnCCR0/1 at the same time. The interrupts of the TAAm will indicate the capture (INTTAAmCC0/1). Figure 10-36 on page 366 shows an example of a 32-bit capture timing. 364 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 START Initial settings for upper 16-bit Timer (TMAAn) * Free-running mode setting (TAAnCTL1: TAAnMD[2:0] = 101B) * Set Capture operation (TAAnOPT0: TAAnCCS[1:0] = 11B) * Set Cascade operation (TAAnOPT1: TAAnCSE = 1) Initial settings for lower 16-bit Timer (TMAAm) * Clock selection (TAAmCTL0: TAAmCKS[2:0]) * Free-running mode setting (TAAmCTL1: TAAmMD[2:0] = 101B) * Set Capture operation (TAAmOPT0: TAAmCCS[1:0] = 11B) TIAAm0 and TIAAm1 edge detection setting (TAAmIS[1:0] and TAAmIS[3:2]) Timer operation enable (TAAmCE = 1) both timer (TMAAm, TMAAn) start TIAAm1 edge detection, capture of lower 16-bit counter value to TAAmCCR1 and upper 16-bit counter value to TAAnCCR1. TIAAm0 edge detection, capture of lower 16-bit counter value to TAAmCCR0 and upper 16-bit counter value to TAAnCCR0. Lower 16-bit counter overflow Upper 16-bit counter overflow Figure 10-35 INTTAAmCC1 output INTTAAmCC0 output INTTAAmOV output INTTAAnOV output Basic Flow of 32-bit Capture Mode User's Manual U18743EE1V2UM00 365 Chapter 10 16-Bit Timer/Event Counter AA TAAmCE = 1 FFFFH D10 D02 16-bit counter TMAAm D12 D00 D01 D11 D03 FFFFH 16-bit counter TMAAn 0002H 0001H 0000H TIAAm0 TAAmCCR0 0000H TAAnCCR0 0000H D00 D 01 0000H 0001H D02 0001H D03 0002H TIAAm1 TAAmCCR1 0000H D10 D11 TAAnCCR1 0000H 0000H 0002H D12 0002H INTTAAmCC0 INTTAAmCC1 INTTAAmOV INTTAAnOV L TOAAm0 TOAAn0 L TOAAm1 TOAAn1 L Figure 10-36 Note Basic Timing of 32-bit Capture Mode m = 0, 2 n = 1,3 As the 32-bit resolution is achieved by cascading two individual TAA, a direct read of the 32-bit capture value is not possible. To ensure that the data is not corrupted during read operation, the following procedure for reading needs to be followed: 366 User's Manual U18743EE1V2UM00 16-Bit Timer/Event Counter AA Chapter 10 START Disable INTTAAmCCR0/1 Clear INTTAAmCCR0/1 pending flag Read TMAAnCCR0/1 and store as upper 16-bit capture value Read TMAAmCCR0/1 and store as lower 16-bit capture value. INTTAAmCCR0/1 pending? Yes No Enable INTTAAmCCR0/1 END Figure 10-37 Flow of 32-bit Read (Capture or Counter Value) Disabling the capture interrupt (INTTAAmCCR0/1) is not required if the read sequence is done in the interrupt service routine, as nesting of the same interrupt is not possible. However, if the read operation is done in a normal routine while the interrupt signal is also assigned to a interrupt service routine, disabling the interrupt is mandatory, otherwise corrupted data might be read. The same flow can be used for reading the timer counter value. In this case the relevant interrupt which pending flags needs to be cleared and checked is INTTAAmOV. Please note that you can either read the upper 16-bit counter (TAAnCNT) and then the lower 16-bit counter (TAAmCNT) or vice versa. While both methods work, the read values can be slightly different, as the count operation of the lower 16-bit counter continues while the upper 16-bit timer is read: * When reading the upper 16-bit first, the lower 16-bit might be incremented during that read. * When reading the lower 16-bit first, the value might be already "old" after reading the upper 16-bit. The software programmer needs to decide which method is considered better for the application. User's Manual U18743EE1V2UM00 367 Chapter 10 16-Bit Timer/Event Counter AA 10.6.10 Capture operation on delayed input clock If during capture operation the first capture event triggers before the first edge of the count clock occurs a value of FFFFH and not a value of 0000H may be stored in the TAAnCCRm registers. (a) Free running mode FFFFH 16-bit counter 0000H Count Clock Sampling Clock TAAnCCR0 0000H FFFFH 0001H TAAnCE TIAAn0 capture trigger input capture trigger input (b) Pulse-width measurement mode FFFFH 16-bit counter 0000H Count Clock Sampling Clock TAAnCCR0 0000H FFFFH 0002H TAAnCE TIAAn0 capture trigger input 368 User's Manual U18743EE1V2UM00 capture trigger input 16-Bit Timer/Event Counter AA User's Manual U18743EE1V2UM00 Chapter 10 369 Chapter 10 370 16-Bit Timer/Event Counter AA User's Manual U18743EE1V2UM00 Chapter 11 16-Bit Interval Timer M The microcontroller includes a 16-bit interval Timer M (TMM0). 11.1 Features Timer M (TMM) supports only a clear & start mode. It does not support a freerunning mode. To use Timer M in a manner equivalent to in the free-running mode, set the compare register to FFFFH and start the 16-bit counter. A match interrupt will occur when the timer overflows. * Interval function * Clock selection x 8 * Simple counter x 1 (The simple counter is a counter that does not use a counter read buffer. This counter cannot be read during timer count operation.) * Simple compare x 1 (The simple compare register is a register that does not use a compare write buffer. No data can be written to this compare register during timer count operation.) * Compare match interrupt x 1 11.2 Configuration TMM consists of the following hardware. Table 11-1 Configuration of TMM Item Configuration Timer register 16-bit counter Register TMM0 compare register 0 (TM0CMP0) Control register TMM0 control register 0 (TM0CTL0) User's Manual U18743EE1V2UM00 371 Chapter 11 16-Bit Interval Timer M Internal bus TM0CTL0 TM0CE TM0CKS2 TM0CKS1 TM0CKS0 INTTM0EQ0 Selector fXP1 fXP1/2 fXP1/4 fXP1/64 fRH/8 or fXP1/512 INTWT fRL/8 fXT Figure 11-1 TM0CMP0 Controller 16-bit counter Clear Block diagram of Timer M 11.3 Timer M Registers (1) TM0CMP0 - TMM0 compare register 0 The TM0CMP0 register is a 16-bit compare register. This register can be read or written in 16-bit units. Reset input clears this register to 0000H. Address: 15 14 13 FFFF F694H 12 11 10 9 8 7 6 TM0CMP0 Caution 372 5 4 3 2 1 0 R/W Initial value R/W 0000 H Changing the TM0CMP0 register contents is prohibited while the timer is operating (TM0CE = 1). Thus rewriting with the same value is permitted. User's Manual U18743EE1V2UM00 16-Bit Interval Timer M (2) Chapter 11 TM0CTL0 - TMM0 control register 0 The TM0CTL0 register is an 8-bit register that controls the operation of TMM. This register can be read or written in 8-bit or 1-bit units. Reset input clears this register to 00H. Address: FFFF F690H Symbol 7 6 5 4 3 2 1 0 R/W After reset TM0CTL0 TM0CE 0 0 0 0 TM0CKS2 TM0CKS1 TM0CKS0 R/W 00 H Caution Changing the TM0CTL0.TM0CKS[2:0] bits is prohibited while the timer is operating (TM0CE = 1). Thus rewriting of these bits with the same value is permitted. The TM0CTL.TM0CE bit can be changed at any time. TM0CE Control of operation of timer M0 0 Disable internal operating clock operation (asynchronously reset TMM0). 1 Enable internal operating clock operation. The TM0CE bit controls the internal operating clock and asynchronously reset of TMM0. When this bit is cleared to 0, the internal operating clock of TMM is stopped, and TMM0 is asynchronously reset. When the TM0CE bit is set to 1, the internal operating clock is enabled within two input clocks, and the timer counts up. SELCNT0 registera TM0CTL0 register SEL07 bit TM0CKS2 TM0CKS1 TM0CKS0 Input PRSI = 0 PRSI = 1 X 0 0 0 fXP1 fXX fXX/2 X 0 0 1 fXP1/2 fXX/2 fXX/4 X 0 1 0 fXP1/4 fXX/4 fXX/8 X 0 1 1 fXP1/64 fXX/64 fXX/128 1 0 0 fXP1/512 fXX/512 fXX/1024 X 1 0 1 INTWT X 1 1 0 fRL/8 X 1 1 1 fXT 0 1 a) Selection of internal count clock fRH/8 Refer to chapter "Clock Generator" on page 179 for details of SELCNT0 register. Note PRSI can be set by the option bytes: Refer to "Flash Memory" on page 259 for details. Caution 1. Set TM0CKS2 to TM0CKS0 bits at TM0CE = 0. When the TM0CE bits is set from 0 to 1, the TM0CKS2 to TM0CKS0 bits can be set at the same time. 2. Set bit 6-3 to 0. User's Manual U18743EE1V2UM00 373 Chapter 11 16-Bit Interval Timer M Note fXX: Main system clock frequency fRL: Low frequency internal oscillator clock frequency (240 KHz) fRH: High frequency internal oscillator clock frequency (8 MHz) fXT: Sub oscillator frequency R 11.4 Operation 11.4.1 Interval timer mode In the interval timer mode, a match interrupt signal (INTTM0EQ0) is output when the value of the 16-bit counter matches the value of TMM0 compare register 0 (TM0CMP0). At the same time, the counter is cleared to 0000H and starts counting up. When FFFFH is set to the TM0CMP0 register, Timer M performs an operation similar to that in the free-running mode. Figure 11-2 Caution 374 Timing of operation in interval timer mode To set M clocks as the interval period, set the TM0CMP0 register to M - 1. User's Manual U18743EE1V2UM00 16-Bit Interval Timer M Chapter 11 11.4.2 Cautions (1) Clock Generator and clock enable timing Because the second clock is the first pulse of the timer count-up signal when the TM0CE bit is changed from 0 to 1, the timer counts one clock less. Figure 11-3 Count operation start timing User's Manual U18743EE1V2UM00 375 Chapter 11 376 16-Bit Interval Timer M User's Manual U18743EE1V2UM00 Chapter 12 Timer AA Synchroneous Operation Timers AA have a timer synchronized operation function, also named tuned operation mode. Master timer and incorporated slave timers of the corresponding timer group (listed in Table 12-1) start and clock synchronously. When the master timer is cleared, the slave timers are cleared synchronously, too. Table 12-1 Setup Synchroneous operation mode of timers Master timer Slave timer V850ES/FE3-L V850ES/FF3-L V850ES/FG3-L TAA0 TAA1 TAA2 TAA3 In the following the procedure is described how to set up the master and slave timer for synchroneous operation. Exemplarily TAAm is used as the master timer, TAAn is used as the slave timer. * Slave timer setup - TAAnCTL1.TAAnSYE = 1: enable synchroneous operation - TAAnCTL1.TAAnMD[2:0] = 101B: free-running mode - TAAnCCR0/1: set compare value * Master timer setup: - TAAmCTL1.TAAmMD[2:0] = 101B: free-running mode = 100B: PWM mode = 111B: triangular wave PWM mode - TAAmCCR0/1: set compare value - TAAmCTL0.TAAmC = 1: enable operation Table 12-2 and Table 12-3 show the timer modes that can be used in the synchroneous operation mode. Table 12-2 Timer modes usable in synchroneous operation mode Master timer Slave timer Free-running mode PWM mode Triangular wave PWM mode TAA0 TAA1 x TAA2 TAA3 x User's Manual U18743EE1V2UM00 377 Chapter 12 Timer AA Synchroneous Operation Table 12-3 Synch channel Timer output functions Free-running mode Timer Pin TAA0 (master) PWM mode Triangular wave PWM mode Synch OFF Synch ON Synch OFF Synch ON Synch OFF Synch ON TOAA00 Toggle Toggle Toggle Toggle N/A N/A TOAA01 Toggle Toggle PWM PWM N/A N/A TAA1 (slave) TOAA10 Toggle Toggle Toggle PWM N/A N/A TOAA11 Toggle Toggle PWM PWM N/A N/A TAA2 (master) TOAA20 Toggle Toggle Toggle Toggle N/A N/A TOAA21 Toggle Toggle PWM PWM N/A N/A TAA3 (slave) TOAA30 Toggle Toggle Toggle PWM N/A N/A TOAA31 Toggle Toggle PWM PWM N/A N/A Ch0 Ch1 The timing of transmitting data from the TAAnCCRm compare register to the CCRm registers is as follows: 378 Free-Running mode: Timing at which the CPU writes the registers ('anytime write'). PWM mode, triangular wave PWM mode: Timing at which timer counter CCR0 and compare register TOAAn0 of master timer match. User's Manual U18743EE1V2UM00 Chapter 13 Watch Timer Functions 13.1 Functions The Watch Timer has the following functions. * Watch Timer * Interval timer The Watch Timer and interval timer functions can be used at the same time. Clear 11-bit prescaler fW 5-bit counter INTWT Clear fW/24 fW/25 fW/26 fW/27 fW/28 fW/210 fW/211 fW/29 Selector fXT Selector Note 1 fBRG Selector Selector Reset INTWTI 3 WTM7 WTM6 WTM5 WTM4 WTM3 WTM2 WTM1 WTM0 Watch timer operation mode register (WTM) Internal bus Figure 13-1 Note Block diagram of Watch Timer 1. The Prescaler3 output fBRG is also used for CSIB0. For details refer to "Clock Generator" on page 179. 2. fXT: Sub oscillator frequency fW: Watch Timer clock frequency INTWT: Watch Timer interrupt INTWTI: Interval timer interrupt User's Manual U18743EE1V2UM00 379 Chapter 13 Watch Timer Functions (1) Watch Timer The Watch Timer generates interrupt requests (INTWT) at time intervals of 0.5 or 0.25 seconds by using the Sub oscillator (nominal fXT = 32.768 KHz). Caution (2) When using a clock fBRG obtained by dividing the main clock fX by Prescaler3 as the Watch Timer count clock fW, set the PRSM0 and PRSCM0 registers according to the main clock frequency that is used so as to obtain a divided clock frequency of 32.768 KHz. If 32.768 KHz cannot be generated, a clock correction software is necessary to realize the watch function. Interval timer The Watch Timer generates an interrupt request (INTWTI) at time intervals specified in advance. Table 13-1 Interval time of interval imer Interval Time x 1/fW 488 s 25 x 1/fW 977 s 2 x 1/fW 1.95 ms 27 x 1/fW 3.91 ms 28 x 1/fW 7.81 ms 2 x 1/fW 15.6 ms 6 9 Note Operation at fW = fXT = 32.768 KHz 24 210 x 1/fW 31.2 ms 211 x 1/fW 62.5 ms fW: Watch Timer clock frequency fXT: Sub oscillator frequency 13.2 Configuration The Watch Timer consists of the following hardware. Table 13-2 Configuration of Watch Timer Item 380 Configuration Counter 5 bits x 1 Prescaler 11 bits x 1 Control register Watch Timer operation mode register (WTM) User's Manual U18743EE1V2UM00 Watch Timer Functions Chapter 13 13.3 Control Registers The Watch Timer operation mode register (WTM) controls the Watch Timer. Before operating the Watch Timer, set the count clock and the interval time. (1) WTM - Watch Timer operation mode register The WTM register enables or disables the count clock and operation of the Watch Timer, sets the interval time of the prescaler, controls the operation of the 5-bit counter, and sets the set time of the watch flag. This register can be read or written in 8-bit or 1-bit units. Reset input clears this register to 00H. Note fXT: Sub oscillator frequency fBRG: Prescaler3 output frequency fW: Watch timer clock frequency User's Manual U18743EE1V2UM00 381 Chapter 13 Watch Timer Functions WTM7 WTM3 WTM2 0 0 0 214/fW (0.5 s: fW = fXT) 0 0 1 213/fW (0.25 s: fW = fXT) 0 1 0 25/fW (977 s: fW = fXT) 0 1 1 24/fW (488 s: fW = fXT) 1 0 0 214/fW (0.5 s: fW = fBRG) 1 0 1 213/fW (0.25 s: fW = fBRG) 1 1 0 25/fW (977 s: fW = fBRG) 1 1 1 24/fW (488 s: fW = fBRG) WTM1 Selection of set time of watch flag Control of 5-bit counter operation 0 Clears after operation stops 1 Starts WTM0 Caution Note Watch timer operation enable 0 Stops operation (clears both prescaler and 5-bit counter) 1 Enables operation Rewrite the WTM2 to WTM7 bits while both the WTM0 and WTM1 bits are 0. 1. fW: Watch Timer clock frequency 2. Values in parentheses apply to operation with fW = 32.768 KHz 13.4 Operation 13.4.1 Operation as Watch Timer The Watch Timer generates an interrupt request at fixed time intervals. The Watch Timer operates using time intervals of 0.5 or 0.25 seconds with the Sub oscillator (32.768 KHz). The count operation starts when the WTM1 and WTM0 bits of the WTM register are set to 11. When the WTM0 bit is cleared to 0, the 11-bit prescaler and 5-bit counter are cleared and the count operation stops. The time of the Watch Timer can be adjusted by clearing the WTM1 bit to 0 and then the 5-bit counter. At this time, an error of up to 15.6 ms may occur. The interval timer may be cleared by clearing the WTM0 bit to 0. However, because the 5-bit counter is cleared at the same time, an error of up to 0.5 seconds may occur when the Watch Timer overflows (INTWT). 382 User's Manual U18743EE1V2UM00 Watch Timer Functions Chapter 13 13.4.2 Operation as interval timer The Watch Timer can also be used as an interval timer that repeatedly generates an interrupt at intervals specified by a preset count value. The interval time can be selected by the WTM4 to WTM7 bits of the WTM register. Table 13-3 WTM7 0 0 WTM6 0 Interval time of itimer WTM5 0 0 0 WTM4 Interval Time 0 24 x 1/fw 488 s (operating at fW = fXT = 32.768 KHz) 1 2 x 1/fw 977 s (operating at fW = fXT = 32.768 KHz) 5 0 0 1 0 2 x 1/fw 1.95 ms (operating at fW = fXT = 32.768 KHz) 0 0 1 1 27 x 1/fw 3.91 ms (operating at fW = fXT = 32.768 KHz) 0 1 0 0 28 x 1/fw 7.81 ms (operating at fW = fXT = 32.768 KHz) 0 1 0 1 29 x 1/fw 15.6 ms (operating at fW = fXT = 32.768 KHz) 0 1 1 0 210 x 1/fw 31.3 ms (operating at fW = fXT = 32.768 KHz) 0 1 1 1 211 x 1/fw 62.5 ms (operating at fW = fXT = 32.768 KHz) 1 0 0 0 24 x 1/fw 488 s (operating at fW = fBRG = 32.768 KHz) 1 0 0 1 25 x 1/fw 977 s (operating at fW = fBRG = 32.768 KHz) 1 0 1 0 26 x 1/fw 1.95 ms (operating at fW = fBRG = 32.768 KHz) 1 0 1 1 27 x 1/fw 3.91 ms (operating at fW = fBRG = 32.768 KHz) 1 1 0 0 28 x 1/fw 7.81 ms (operating at fW = fBRG = 32.768 KHz) 1 1 0 1 29 x 1/fw 15.6 ms (operating at fW = fBRG = 32.768 KHz) 1 1 1 0 210 x 1/fw 31.3 ms (operating at fW = fBRG = 32.768 KHz) 1 1 1 1 211 x 1/fw 62.5 ms (operating at fW = fBRG = 32.768 KHz) Note 6 fW: Watch Timer clock frequency fXT: Sub oscillator frequency fBRG: Prescaler3 output frequency User's Manual U18743EE1V2UM00 383 Chapter 13 Watch Timer Functions 5-bit counter 0H Overflow Start Overflow Count clock fW or fW/29 Watch timer interrupt INTWT Interrupt time of watch timer (0.5 s) Interrupt time of watch timer (0.5 s) Interval timer interrupt INTWTI Interval time (T) Interval time (T) nT Figure 13-2 Note nT Operation Timing of Watch Timer/Interval Timer fW: Watch Timer clock frequency Values in parentheses apply to operation with count clock fW = 32.768 KHz. n: Number of interval timer operations 13.4.3 Cautions The following time is required before the first Watch Timer interrupt request signal (INTWT) is generated after operation is enabled (WTM1 and WTM0 bits of WTM register = 1). It takes 0.515625 seconds for the first INTWT signal to be generated (29 x 1/32768 = 0.015625 s longer). The INTWT signal is then generated every 0.5 seconds. WTM0, WTM1 0.515625 s 0.5 s 0.5 s INTWT Figure 13-3 384 Example of generation of Watch Timer interrupt request signal (INTWT) (when interrupt period = 0.5 s) User's Manual U18743EE1V2UM00 Chapter 14 Watchdog Timer 2 14.1 Functions Watchdog Timer 2 has the following functions. * Default-start Watchdog Timer * Reset mode: Reset operation upon overflow of Watchdog Timer 2 (generation of WDT2RES signal) * Non-maskable interrupt request mode: NMI operation upon overflow of Watchdog Timer 2 (generation of INTWDT2 signal) * Input selectable from main clock and 240 KHz internal oscillator as the source clock Caution 1. Watchdog Timer 2 is automatically started after reset release. Source clock is a 240 KHz internal oscillator. 2. By flash mask option, operation of WDT2 can be set fixed to 240 KHz internal oscillator source clock and reset mode. Only the interval time can be changed. Changing of clock source and operation mode is not possible. 3. In case WDT2 shall not be used or clock source and operation mode shall be changed, flash mask option should not be set for fixing 240 KHz internal oscillator source clock and reset mode. In this case, after reset, the settings should be changed before the first WDT2 overflow. Alternatively WDT2 should be cleared once, and required changes should be performed within the next interval time. 4. The WDTM2 register can be written only once after reset. Even if the default setting of WDTM2 shall not be changed, it is recommended to once write the default value to WDTM2 in order to activate the write protection mechanism. 5. The RETI instruction can not be used to restore from the interrupt service routine of the non-maskable INTWDT2. Therefore a system reset must be performed after completion of the INTWDT2 service routine. User's Manual U18743EE1V2UM00 385 Chapter 14 Watchdog Timer 2 fX/128 Clock input controller fRL/8 16-bit counter 2 fX/216 to fX/223 fRL/212 to fRL/219 Selector 3 Clear 0 RUN2 Output controller INTWDT2 WDT2RES (internal reset signal) 3 WDM21 WDM20 WDCS24 WDCS23 WDCS22 WDCS21 WDCS20 Watchdog timer mode register 2 (WDTM2) Watchdog timer enable register (WDTE) Internal bus Figure 14-1 Note Block diagram of Watchdog Timer 2 fX: fRL: INTWDT2: WDT2RES: Oscillation frequency Internal oscillator clock frequency Non-maskable interrupt request signal from Watchdog Timer 2 Watchdog Timer 2 reset signal 14.2 Configuration Watchdog Timer 2 consists of the following hardware. Table 14-1 Configuration of Watchdog Timer 2 Item Control registers 386 Configuration Watchdog Timer mode register 2 (WDTM2) Watchdog Timer enable register (WDTE) User's Manual U18743EE1V2UM00 Watchdog Timer 2 Chapter 14 14.3 Control Registers (1) WDTM2 - Watchdog Timer 2 mode register The WDTM2 register sets the operation mode, operation clock and overflow time of Watchdog Timer 2. Access Address Initial Value Table 14-2 The register can be read/written in 8-bit units. This register can be read any number of times, but it can be written only once following reset release. FFFF F6D0H 67H. The register is initialized by any reset. 7 6 0 WDM21 5 R/W R/W 4 3 2 1 0 WDM20 WDCS24 WDCS23 WDCS22 WDCS21 WDCS20 R/W R/W R/W R/W R/W R/W Selection of operation mode WDM21 WDM20 Function 0 0 Stops operation 0 1 Non-maskable interrupt request mode (generation of INTWDT2) 1 x Reset mode (generation of RESWDT2) User's Manual U18743EE1V2UM00 387 Chapter 14 Watchdog Timer 2 Table 14-3 Watchdog Timer 2 Clock Selection WDCS24 WDCS23 WDCS22 WDCS21 WDCS20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 Selected clock period 240 KHz (typ.) 212/fRL 17.1 ms 0 1 13 2 /fRL 34.1 ms 0 214 68.3 ms 1 215 136.5 ms 0 16 2 /fRL 273.1 ms 1 217 546.1 ms 0 218 1,092.3 ms 19 2,184.5 ms /fRL /fRL /fRL /fRL 1 2 /fRL (default) 0 216/f 1 217f 0 18/f 2 1 219/f 0 220/f 1 21/f fX = 4 MHz fX = 16 MHz X 16.4 ms 4.1 ms X 32.8 ms 8.2 ms X 65.5 ms 16.4 ms X 131.1 ms 32.8 ms X 262.1 ms 65.3 ms 2 X 524.3 ms 131.1 ms 0 222/f X 1,048.6 ms 262.2 ms X 2,097.2 ms 524.3 ms 0 1 1 1 1 223/f 1 x x x x Stop Caution 1. If the WDTM2 register is rewritten twice after reset, an overflow signal is forcibly generated. If the Watchdog Timer has stopped operation, WDTM2 can be written several times without generating an overflow. 2. To stop WDT2 securely, * stop the internal oscillator by RCM.RSTOP = 1 (must be permitted by flash mask options) * set WDTM2 = 1FH 3. In order to ensure that the Watchdog Timer does not overflow, and thus generate a watchdog event, during the register settings are changed, write to WDTE first for restarting the timer. 388 User's Manual U18743EE1V2UM00 Watchdog Timer 2 (2) Chapter 14 WDTE - Watchdog Timer enable register The counter of Watchdog Timer 2 is cleared and counting restarted by writing ACH to the WDTE register. Access Address Initial Value Caution The register can be read/written in 8-bit units. FFFF F6D1H 9AH. The register is initialized by any reset. 7 6 5 4 3 2 1 0 R/W R/W R/W R/W R/W R/W R/W R/W 1. When a value other than ACH is written to the WDTE register, an overflow signal is forcibly output. 2. When a 1-bit memory manipulation instruction is executed for the WDTE register, an overflow signal is forcibly output. 3. The read value of the WDTE register is 9AH (which differs from written value ACH). 14.4 Watchdog Timer Operation Watchdog Timer 2 automatically starts in the reset mode after reset is released. The WDTM2 register can be written only once following reset using byte access. To use watchdog timer 2, write the operation mode and the interval time to the WDTM2 register using an 8-bit memory manipulation instruction. After this, the operation of watchdog timer 2 cannot be stopped/changed again. The WDCS24 to WDCS20 bits of the WDTM2 register are used to select the watchdog timer 2 loop detection time interval. Writing ACH to the WDTE register clears the counter of watchdog timer 2 and starts the count operation again. After the count operation has started, write ACH to WDTE within the loop detection time interval. If the time interval expires without ACH being written to the WDTE register, a reset signal (WDT2RES) or a non-maskable interrupt request signal (INTWDT2) is generated, depending on the set values of the WDM21 and WDM20 bits of the WDTM2 register. When not using watchdog timer 2, write 1FH to the WDTM2 register. If the non-maskable interrupt request mode is set, execution cannot return from non-maskable interrupt servicing by using the RETI instruction. Therefore, execute system reset after completion of interrupt servicing. User's Manual U18743EE1V2UM00 389 Chapter 14 Watchdog Timer 2 14.5 Watchdog Timer Operation in Power Save Mode If the Watchdog Timer overflows while the device is in power save mode, following procedures take place: * Watchdog Timer in reset operation mode (WDTM2.WDM21 = 1): A device RESET is executed. * Watchdog Timer in NMI operation mode (WDTM2.WDM2[1:0] = 01B): The NMI is not served, the device wakes up from power save mode and continues with normal operation. 390 User's Manual U18743EE1V2UM00 Chapter 15 Asynchronous Serial Interface (UARTD) The V850ES/Fx3-L microcontrollers have following instances of the Universal Asynchronous Serial Interface UARTD: UARTD V850ES/FE3-L Instances Names V850ES/FF3-L V850ES/FG3-L 2 3 UARTD0 to UART1 UARTD0 to UART2 Throughout this chapter, the individual instances of UARTD are identified by "n", for example, UDnCTL0 for the UARTDn control register 0. 15.1 Features * Transfer rate: 300 bps to 1500 kbps (using dedicated baud rate generator) * Full-duplex communication: - Internal UARTD receive data register n (UDnRX) - Internal UARTD transmit data register n (UDnTX) * 2-pin configuration: - TXDDn: Transmit data output pin - RXDDn: Receive data input pin * Reception error and status output function - Parity error - Framing error - Overrun error - Data consistency error - SBF receive error * Interrupt sources: 3 - Reception complete interrupt (INTUDnR): This interrupt occurs upon transfer of receive data from the shift register to receive buffer register n after serial transfer completion, in the reception enabled status. - Transmission enable interrupt (INTUDnT): This interrupt occurs upon transfer of transmit data from the transmit buffer register to the shift register in the transmission enabled status. - Status interrupt (INTUDnS): This interrupt occurs upon reception of erroneous data and the data consistency and SBF reception during LIN communication. * Character length: 7, 8 bits * Parity function: odd, even, 0, none * Transmission stop bit: 1, 2 bits User's Manual U18743EE1V2UM00 391 Chapter 15 Asynchronous Serial Interface (UARTD) * On-chip dedicated baud rate generator * MSB-/LSB-first transfer selectable * Transmit/receive data inverted input/output possible * 13 to 20 bits selectable for the SBF (Sync Break Field) in the LIN (Local Interconnect Network) communication format - Recognition of 11 bits or more possible for SBF reception in LIN communication format - SBF reception flag provided * SBF reception can be detected during data communication. * Bus monitor function to keep data consistency of the transmit data 15.2 Configuration The block diagram of the UARTDn is shown below. Internal bus INTUDnT INTUDnR INTUDnS Reception unit Transmission unit UDnRX Receive shift register Filter UDnTX Reception controller Transmission controller Send and receive data comparison Baud rate generator Baud rate generator Transmit shift register Selector RXDDn Clock selector Selector fXP1 or fXP2 fXP1/2 fXP1/4 ... fXP1/1024 ASCKD0Note TXDDn UDnCTL1 UDnCTL2 UDnCTL0 UDnSTR UDnOTP0 UDnOTP1 Internal bus Note: External clock ASCKD0 is only available for UARTD0 Figure 15-1 Note 392 Block diagram of Asynchronous Serial Interface UARTDn For the configuration of the baud rate generator, see Figure 15-11 on page 419. User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Chapter 15 UARTDn consists of the following hardware units. Table 15-1 (1) Configuration of UARTDn Item Configuration Registers UARTDn control register 0 (UDnCTL0) UARTDn control register 1 (UDnCTL1) UARTDn control register 2 (UDnCTL2) UARTDn option control register 0 (UDnOPT0) UARTDn status register (UDnSTR) UARTDn receive shift register UARTDn receive data register (UDnRX) UARTDn transmit shift register UARTDn transmit data register (UDnTX) UARTDn control register 0 (UDnCTL0) The UDnCTL0 register is an 8-bit register used to specify the UARTDn operation. (2) UARTDn control register 1 (UDnCTL1) The UDnCTL1 register is an 8-bit register used to select the input clock for the UARTDn. (3) UARTDn control register 2 (UDnCTL2) The UDnCTL2 register is an 8-bit register used to control the baud rate for the UARTDn. (4) UARTDn option control register 0 (UDnOPT0) The UDnOPT0 register is an 8-bit register used to control the serial transfer for the UARTDn. (5) UARTDn option control register 1 (UDnOPT1) The UDnOPT1 register is an 8-bit register used to control the serial transfer for the UARTDn. (6) UARTDn status register (UDnSTR) The UDnSTRn register consists of flags indicating the error contents when a reception error occurs, the inconsistency between transmit and receive data and successful SBF reception during LIN communication. Each one of the reception error flags is set (to 1) upon occurrence of a reception error and is reset (to 0) by reading the UDnSTR register. (7) UARTDn receive shift register This is a shift register used to convert the serial data input to the RXDDn pin into parallel data. Upon reception of 1 byte of data and detection of the stop bit, the receive data is transferred to the UDnRX register. This register cannot be manipulated directly. User's Manual U18743EE1V2UM00 393 Chapter 15 Asynchronous Serial Interface (UARTD) (8) UARTDn receive data register (UDnRX) The UDnRX register is an 8-bit register that holds receive data. When 7 characters are received, 0 is stored in the highest bit (when data is received LSB first). In the reception enabled status, receive data is transferred from the UARTDn receive shift register to the UDnRX register in synchronization with the completion of shift-in processing of 1 frame. Transfer to the UDnRX register also causes the reception complete interrupt request signal (INTUDnR) to be output. (9) UARTDn transmit shift register The transmit shift register is a shift register used to convert the parallel data transferred from the UDnTX register into serial data. When 1 byte of data is transferred from the UDnTX register, the shift register data is output from the TXDDn pin. This register cannot be manipulated directly. (10) UARTDn transmit data register (UDnTX) The UDnTX register is an 8-bit transmit data buffer. Transmission starts when transmit data is written to the UDnTX register. When data can be written to the UDnTX register (when data of one frame is transferred from the UDnTX register to the UARTDn transmit shift register), the transmission enable interrupt request signal (INTUDnT) is generated. 394 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Chapter 15 15.3 UARTD Registers (1) UDnCTL0 - UARTDn control register 0 The UDnCTL0 register is an 8-bit register that controls the UARTDn serial transfer operation. This register can be read or written in 8-bit or 1-bit units. Reset input sets this register to 10H. UD2CTL0 FFFFFA20H, UD3CTL0 FFFFFA30H, UD4CTL0 FFFFFA40H, UD5CTL0 FFFFFA50H UD6CTL0 FFFFFA60H, UD7CTL0 FFFFFA70H 7 UDnCTL0 6 5 4 UDnPWR UDnTXE UDnRXE UDnDIR UDnPWR 3 2 UDnPS1 UDnPS0 1 0 UDnCL UDnSL UARTDn operation control 0 Disable UARTDn operation (UARTDn reset asynchronously) 1 Enable UARTDn operation The UARTDn operation is controlled by the UDnPWR bit. The TXDDn pin output is fixed to high level by clearing the UDnPWR bit to 0 (fixed to low level if UDnOPT0.UDnTDL bit = 1). UDnTXE Transmission operation enable 0 Disable transmission operation 1 Enable transmission operation * To start transmission, set the UDnPWR bit to 1 and then set the UDnTXE bit to 1. To stop transmission clear the UDnTXE bit to 0 and then UDnPWR bit to 0. * To initialize the transmission unit, clear the UDnTXE bit to 0, wait for two cycles of the base clock, and then set the UDnTXE bit to 1 again. UDnRXE Reception operation enable 0 Disable reception operation 1 Enable reception operation * To enable reception, set the UDnPWR bit to 1 and then set the UDnRXE bit to 1. * To stop reception, clear the UDnRXE bit to 0 and then UDnPWR bit to 0. * To initialize the reception unit, clear the UDnRXE bit to 0, wait for two periods of the base clock, and then set the UDnRXE bit to 1 again. The reception is enabled after the UDnRXE bit is set to 1 and two cycles of base clock have passed. The rising edge detection of the RXDD pin is enabled after the UDnRXE bit is set to 1 and four cycles of the base clock have passed. User's Manual U18743EE1V2UM00 395 Chapter 15 Asynchronous Serial Interface (UARTD) UDnDIR Transfer direction selection 0 MSB-first transfer 1 LSB-first transfer This register can be rewritten only when the UDnPWR bit = 0 or the UDnTXE bit = the UDnRXE bit = 0. When the transmission/reception is performed in the LIN format, set the UDnDIR bit to 1. UDnPS1 UDnPS0 Parity selection during transmission Parity selection during reception 0 0 No parity output Reception with no parity 0 1 0 parity output Reception with 0 parity 1 0 Odd parity output Odd parity check 1 1 Even parity output Even parity check * This register is rewritten only when the UDnPWR bit = 0 or the UDnTXE bit = the UDnRXE bit = 0. * If "Reception with 0 parity" is selected during reception, a parity check is not performed. Therefore, since the UDnSTR.UDnPE bit is not set, no error interrupt is output. * When transmission and reception are performed in the LIN format, clear the UDnPS1 and UDnPS0 bits to 00. UDnCL Specification of data character length of 1 frame of transmit/receive data 0 7 bits 1 8 bits * This register can be rewritten only when the UDnPWR bit = 0 or the UDnTXE bit = the UDnRXE bit = 0. * When the transmission/reception is performed in the LIN format, set the UDnCL bit to 1. Specification of length of stop bit for transmit data UDnSL 0 1 bit 1 2 bits This register can be rewritten only when the UDnPWR bit = 0 or the UDnTXE bit = the UDnRXE bit = 0. Note (2) For details of parity, see "Parity types and operations" on page 416. UDnCTL1- UARTDn control register 1 For details, see "UDnCTL1 - UARTDn control register 1" on page 420. (3) UDnCTL2 - UARTDn control register 2 For details, see "UDnCTL2 - UARTDn control register 2" on page 421. 396 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) (4) Chapter 15 UDnOPT0 - UARTDn option control register 0 The UDnOPT0 register is an 8-bit register that controls the serial transfer operation of the UARTDn register. This register can be read or written in 8-bit or 1-bit units. Reset input sets this register to 14H.. After reset: 04H Address: UD0OPT0: FFFFFA03, UD1OPT0: FFFFFA13 UD2OPT0: FFFFFA23, UD3OPT0: FFFFFA33 UD4OPT0: FFFFFA43, UD5OPT0: FFFFFA53 UD6OPT0: FFFFFA63, UD7OPT0: FFFFFA73 7 6 5 4 3 2 1 0 UDnOPT0 UDnSRF UDnSRT UDnSTT UDnSLS2 UDnSLS1 UDnSLS0 UDnTDL UDnRDL R/W R/W R/W R/W R/W R/W R/W R/W R/W UDnSRF SBF reception flag 0 When the UDnCTL0.UDnPWR bit = UDnCTL0.UDnRXE bit = 0 are set. Also upon normal end of SBF reception. 1 During SBF reception. * SBF (Sync Brake Field) reception is judged during LIN communication. * The UDnSRF bit is held at 1 when an SBF reception error occurs, and then if the SBF reception is started again and ended normally, the UDnSRF bit is cleared to 0.Clearing by the instruction is disabled. * UDnSRF bit is read-only. When the UDnSRF = 1, the judgment process that SBF reception ended normally differs depending on the values of the SBF reception mode selection bit (UDnSRS). If the UDnSRS bit = 0, when any high level inputs including noises are applied to the reception input data even only for a second, the judgment of whether the low level period is more than 11 bits or not is executed. If the UDnSRS bit = 1, the received input data is sampled along with the set baud rate and when the low level period is 11 bits or more, it is judged as the successful SBF reception. UDnSRT SBF reception trigger 0 - 1 SBF reception trigger. * This is the SBF reception trigger bit during LIN communication, and when read, "0" is always read. For SBF reception, set the UDnSRT bit (to 1) to enable SBF reception. * Set the UDnSRT bit after setting the UDnCTL0.UDnPWR bit and UDnCTL0.UDnRXE bit = 1. * The UDnSRT bit can be set during the reception but the reception is aborted. The updating of the status flag, output of the interrupt request flag, and the data saving are not performed so the receive data set during the reception is not guaranteed. * After the UDnSRT bit is set, re-setting of the UDnSRT bit is disabled until the SBF reception is succeeded, UDnSRF is cleared, and the interrupt request signal is fallen. * The detection of the SBF reception starts at the next falling edge of the reception input data. If the UDnSRT is set during the SBF reception, the SBF cannot be received, so other reception operations are not performed until the next SBF reception is succeeded. User's Manual U18743EE1V2UM00 397 Chapter 15 Asynchronous Serial Interface (UARTD) UDnSTT SBF transmission trigger 0 1 SBF transmition triggerNote . * This is the SBF transmittion trigger bit during LIN communication, and when read, "0" is always read. * Set the UDnSTT bit after setting the UDnPWR bit = UDnTXE bit = 1. Note 1. To cancel the SBF reception enable status without receiving the SBF, set the UDnPWR bit = 0 or UDnRXE bit = 0. 2. The confirmation method of SBF receive completion while the UDnSRT bit is set depends on the values of the SBF reception mode selection bit (UDnSRS). If the UDnSRS bit is cleared to 0, it is confirmed by receive completion interrupt which is detected after the setting of the SBF reception trigger bit. If the UDnSRS bit is set to 1, it is confirmed by whether the SBF receive success flag (UDnSSF) is 1 when status interrupt is detected after the setting of the SBF reception trigger bit. It can also be confirmed by the UDnSRF bit = 0 after the receive interrupt or the status interrupt is detected. In any case, after the SBF reception is completed, the UART normal reception is operated at the next reception. 3. Data transmission while UDnDCS bit = 1 during UDnSRF bit = 1 is prohibited. However, the SBF transmission is enabled. Before starting the SBF transmission by UDnOPT0.UDnSTT=1 make sure that no data transfer is ongoing, that means check that UDnSTR.UDnTSF=0. SBF transmit length selection UDnSLS2 UDnSLS1 UDnSLS0 1 0 1 13-bit output (reset value) 1 1 0 14-bit output 1 1 1 15-bit output 0 0 0 16-bit output 0 0 1 17-bit output 0 1 0 18-bit output 0 1 1 19-bit output 1 0 0 20-bit output This register can be set when the UDnPWR bit = 0 or when the UDnTXE bit = 0. Transmit data level bit UDnTDL 0 Normal output of transfer data 1 Inverted output of transfer data * The output level of the TXDDn pin can be inverted using the UDnTDL bit. * This register can be set when the UDnPWR bit = 0 or when the UDnTXE bit = 0. UDnRDL Receive data level bit 0 Normal input of transfer data 1 Inverted input of transfer data * The output level of the RXDDn pin can be inverted using the UDnRDL bit. * This register can be set when the UDnPWR bit = 0 or the UDnRXE bit = 0. Note 398 The UDnTDL bit control inverts the TXDDn output level regardless of the values of the UDnPWR and UDnTXE bits. Therefore, if the UDnTDL bit is set to 1 while the operation is disabled, the TXDDn outputs the low level. User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) (5) Chapter 15 UDnOPT1 - UARTDn option control register 1 The UDnOPT1 register is an 8-bit register that controls the serial transfer operation of the UARTDn register. This register can be read or written in 8-bit units. Reset input sets this register to 00H. After reset: 00H Address: UD0OPT1: FFFFFA05, UD1OPT1: FFFFFA15 UD2OPT1: FFFFFA25, UD3OPT1: FFFFFA35 UD4OPT1: FFFFFA45, UD5OPT1: FFFFFA55 UD6OPT1: FFFFFA65, UD7OPT1: FFFFFA75 7 6 5 4 3 2 1 0 UDnOPT1 0 0 0 0 0 0 UDnSRS UDnDCS R/W R/W R/W R/W R/W R/W R/W R/W R/W UDnSRS Note SBF reception mode selection bit 0 A new SBF can't be detected while the communication is in progress.When the low level is detected at the stop bit position, it is recognized as framing error. 1 A new SBF can be detected while the communication is in progress.When the low level is detected at the stop bit position a waiting state is generated until high level is detected. When the width of the low level is 11 bits or more, it is recognized as new SBF. 1. This bit should only be set when the LIN communication is used. Otherwise set this bit to 0. 2. When this bit is set to 1, it is necessary to set UD0DCS to 1. UDnDCS Data consistency check selection bit 0 Data consistency is not checked 1 Data consistency is checked When data is transmitted using the LIN protocoll, this bit selects the handling of the consistency checking of data. When UDNDCS = 1 the transmitted data and received data are compared and the mismatch is detected. In that case a status interrupt request signal (UDTIS) is generated. Note 1. This bit should only be set when the LIN communication is used. Otherwise set this bit to 0. 2. When this bit is used, the data bit length doesn't prohibits the eight bit fixation and the addition of the parity bit. User's Manual U18743EE1V2UM00 399 Chapter 15 Asynchronous Serial Interface (UARTD) (6) UDnSTR - UARTDn status register The UDnSTR register is an 8-bit register that displays the UARTDn transfer status and reception error contents. This register can be read or written in 8-bit or 1-bit units, but the UDnTSF bit is a read-only bit, while the UDnSSF, UDnDCE, UDnPE, UDnFE, and UDnOVE bits can both be read and written. However, these bits can only be cleared by writing 0; they cannot be set by writing 1 (even if 1 is written to them, the value is retained). The initialization conditions are shown below. Note Register/Bit Initialization conditions UDnSTR register * Reset * UDnCTL0.UDnPWR = 0 UDnSSF * UDnCTL0.UDnRXE = 0 * UDnOPT1.UDnSRS = 0 UDnDCE * UDnCTL0.UDnRXE = 0 * UDnOPT1.UDnDCS = 0 UDnTSF bit * UDnCTL0.UDnTXE = 0 UDnPE, UDnFE, UDnOVE bits * 0 write * UDnCTL0.UDnRXE = 0 To clear the status flag, use a 1-bit manipulation instruction or write the inverted value of the read value using a 8-bit manipulation instruction to clear all bits together. After reset: 00H Address: UD0STR: FFFFFA04, UD1STR: FFFFFA14 UD2STR: FFFFFA24, UD3STR: FFFFFA34 UD4STR: FFFFFA44, UD5STR: FFFFFA54 UD6STR: FFFFFA64, UD7STR: FFFFFA74 7 6 5 4 3 2 1 0 UDnSTR UDnTSF 0 0 UDnSSF UDnDCE UDnPE UDnFE UDnOVE R/W R R/W R/W R/W R/W R/W R/W R/W UDnTSF Transfer status flag 0 * When the UDnPWR bit = 0 or the UDnTXE bit = 0 has been set. * When, following transfer completion, there was no next data transfer from UDnTX register * When there is no next transmit data at the UDnTX bit after the SBF transmission has been completed 1 * Write to UDnTXB bit * When the SBF transmission trigger bit (UDnSST) is set The UDnTSF bit is always 1 when performing continuous transmission. When initializing the transmission unit, check that the UDnTSF bit = 0 before performing initialization. The transmit data is not guaranteed when initialization is performed while the UDnTSF bit = 1. During the communication the UDnTSF bit is cleared after 2 clocks. 400 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) UDnSSF Chapter 15 SBF receive successful flag 0 When the UDnPWR bit = 1or the UDnRXE bit = 0 or the UDnSRS bit = 0 or the UDnSSF bit = 0 has been set 1 When a consecutive low level (SBF) of 11 bits or more is received and the SBF reception mode bit UDnSRS has been set. When the SBF receive mode selection bit is set in LIN communication mode, it is necessary to read this bit by the status interrupt processing and to confirm the beginning of a new frame slot. This bit is maintained until 0 is written. It is always 0 for UD0SRS = 0. When 1 is written to this bit, the value is retained. UDnDCE Data consistency error flag 0 When the UDnPWR bit = 0 or the UDnTXE bit = 0 or the UDnDCS bit = 0 or UDnDCE bit = 0 has been set. 1 This bit is set when the transmit data is not consistent to receive data in LIN communication mode. The send data is compared with the receive data when data is transmitted in LIN communication mode. When a mismatch is detected, this bit becomes 1. The bit is maintained until 0 is written. It is always 0 for UD0DCS = 0. When 1 is written to this bit, the value is retained. UDnPE Parity error flag 0 * When the UDnPWR bit = 0 or the UDnRXE bit = 0 has been set. * When 0 has been written 1 When parity of data and parity bit do not match during reception. * The operation of the UDnPE bit is controlled by the settings of the UDnCTL0.UDnPS1 and UDnCTL0.UDnPS0 bits. * The UDnPE bit can be read and written, but it can only be cleared by writing 0 to it, and it cannot be set by writing 1 to it. When 1 is written to this bit, the value is retained. UDnFE Framing error flag 0 * When the UDnPWR bit = 0 or the UDnRXE bit = 0 has been set * When 0 has been written 1 When no stop bit is detected during reception * Only the first bit of the receive data stop bits is checked, regardless of the value of the UDnCTL0.UDnSL bit. * The UDnFE bit can be both read and written, but it can only be cleared by the value is retained writing 0 to it, and it cannot be set by writing 1 to it. When 1 is written to this bit. UDnOVE Overrun error flag 0 * When the UDnPWR bit = 0 or the UDnRXE bit = 0 has been set. * When 0 has been written 1 When receive data has been set to the UDnRXB register and the next receive operation is completed before that receive data has been read * When an overrun error occurs, the data is discarded without the next receive data being written to the receive buffer. * The UDnOVE bit can be both read and written, but it can only be cleared by writing 0 to it. When 1 is written to this bit, the value is retained User's Manual U18743EE1V2UM00 401 Chapter 15 Asynchronous Serial Interface (UARTD) (7) UDnRX - UARTDn receive data register The UDnRX register is an 8-bit buffer register that stores parallel data converted by the receive shift register. The data stored in the receive shift register is transferred to the UDnRX register upon completion of reception of 1 byte of data. During LSB-first reception when the data length has been specified as 7 bits, the receive data is transferred to bits 6 to 0 of the UDnRX register and the MSB always becomes 0. During MSB-first reception, the receive data is transferred to bits 7 to 1 of the UDnRX register and the LSB always becomes 0. When an overrun error (UDnOVE) occurs, the receive data at this time is not transferred to the UDnRX register and is discarded. This register is read-only, in 8-bit units. In addition to reset input, the UDnRX register can be set to FFH by clearing the UDnCTL0.UDnPWR bit to 0. After reset: FFH 7 R Address: UD0RX FFFFFA06H, UD1RX FFFFFA16H, UD2RX FFFFFA26H, UD3RX FFFFFA36H , UD4RX FFFFFA46H 6 5 4 3 2 1 0 UDnRX (8) UDnTX - UARTDn transmit data register The UDnTX register is an 8-bit register used to set transmit data. This register can be read or written in 8-bit units. Reset input sets this register to FFH. After reset: FFH 7 R/W Address : UD0TX FFFFFA07H, UD1TX FFFFFA17H, UD2TX FFFFFA27H, UD3TX FFFFFA37H, UD4TX FFFFFA47H 6 5 4 3 2 1 0 UDnTX When the transmission is enabled (UDnPWR = 1 and UDnTXE = 1) the write to the UDnTX register triggers the start of the transmission. Be sure to execute the transmit data write during transmission after the transmission interrupt request (INTUDnT) is generated. If the the next data is written before the transmission is completed the continuous transmission is enabled. 402 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Chapter 15 15.4 Interrupt Request Signals The following three interrupt request signals are generated from UARTDn. * Reception complete interrupt request signal (INTUDnR) * Status interrupt request signal (INTUDnS) * Transmission enable interrupt request signal (INTUDnT) (1) Reception complete interrupt request signal (INTUDnR) A reception complete interrupt request signal is output when data is shifted into the receive shift register and transferred to the UDnRX register in the reception enabled status. In case of erroneous reception, the status interrupt INTUDnS is generated instead of INTUDnR. No reception complete interrupt request signal is generated in the reception disabled status. (2) Transmission enable interrupt request signal (INTUDnT) If transmit data is transferred from the UDnTX register to the UARTDn transmit shift register with transmission enabled, the transmission enable interrupt request signal is generated. (3) Status interrupt request signal (INTUDnS) A status interrupt request is generated if an error condition occurred during reception, as reflected by UDnSTR.UDnPE (parity error flag), UDnSTR.UDnFE (framing error flag), UDnSTR.UDnOVE (overrun error flag), the data is not consistent between data transmit and data reception. When the SBF reception mode selection bit is set in LIN communication mode (UDnSRS bit = 1), the status interrupt request signal is generated when a consecutive low level (SBF) of 11 bits or more is received. User's Manual U18743EE1V2UM00 403 Chapter 15 Asynchronous Serial Interface (UARTD) 15.5 Operation 15.5.1 Data format Full-duplex serial data reception and transmission is performed. As shown in the figures below, one data frame of transmit/receive data consists of a start bit, character bits, parity bit, and stop bit(s). Specification of the character bit length within 1 data frame, parity selection, specification of the stop bit length, and specification of MSB/LSB-first transfer are performed using the UDnCTL0 register. Moreover, control of UART output/inverted output for the TXDDn bit is performed using the UDnOPT0.UDnTDL bit. (1) * Start bit 1 bit * Character bits 7 bits/8 bits * Parity bit parity/no parity Even parity/odd parity/0 * Stop bit 1 bit/2 bits UARTD transmit/receive data format (a) 8-bit data length, LSB first, even parity, 1 stop bit, transfer data: 55H 1 data frame Start bit D0 D1 D2 D3 D4 D5 D6 D7 Parity Stop bit bit (b) 8-bit data length, MSB first, even parity, 1 stop bit, transfer data: 55H 1 data frame Start bit 404 D7 D6 D5 User's Manual U18743EE1V2UM00 D4 D3 D2 D1 D0 Parity Stop bit bit Asynchronous Serial Interface (UARTD) Chapter 15 (c) 8-bit data length, MSB first, even parity, 1 stop bit, transfer data: 55H, TXDDn inversion 1 data frame Start bit D7 D6 D5 D4 D3 D2 D1 D0 Parity Stop bit bit (d) 7-bit data length, LSB first, odd parity, 2 stop bits, transfer data: 36H 1 data frame Start bit D0 D1 D2 D3 D4 D5 D6 Parity Stop bit bit Stop bit (e) 8-bit data length, LSB first, no parity, 1 stop bit, transfer data: 87H 1 data frame Start bit D0 D1 D2 User's Manual U18743EE1V2UM00 D3 D4 D5 D6 D7 Stop bit 405 Chapter 15 Asynchronous Serial Interface (UARTD) 15.5.2 SBF transmission/reception format The UARTD has an SBF (Sync Break Field) transmission/reception control function to enable use of the LIN function. About LIN LIN stands for Local Interconnect Network and is a low-speed (1 to 20 kbps) serial communication protocol intended to aid the cost reduction of an automotive network. LIN communication is single-master communication, and up to 15 slaves can be connected to one master. The LIN slaves are used to control the switches, actuators, and sensors, and these are connected to the LIN master via the LIN network. Normally, the LIN master is connected to a network such as CAN (Controller Area Network). In addition, the LIN bus uses a single-wire method and is connected to the nodes via a transceiver that complies with ISO9141. In the LIN protocol, the master transmits a frame with baud rate information and the slave receives it and corrects the baud rate error. Therefore, communication is possible when the baud rate error in the slave is 15% or less. Figure 15-2 and Figure 15-3 outline the transmission and reception manipulations of LIN. Wake-up signal frame Synch break field Synch field Note 2 13 bits 55H transmission Ident field DATA field DATA field Check SUM field Data transmission Data transmission Data transmission LIN-bus Note 3 8 bits Note 1 Data transmission TXDDn (output) SBF transmissionNote 4 INTUDnR interrupt Figure 15-2 Note LIN transmission manipulation outline 1. The interval between each field is controlled by software. 2. SBF output is performed by hardware. The output width is the bit length set by the UDnOPT0.UDnSBL2 to UDnOPT0.UDnSBL0 bits. If even finer output width adjustments are required, such adjustments can be performed using the UDnCTLn.UDnBRS7 to UDnCTLn.UDnBRS0 bits. 3. 80H transfer in the 8-bit mode is substituted for the wakeup signal frame. 406 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Chapter 15 4. A transmission enable interrupt request signal (INTUDnT) is output at the start of each transmission. The INTUDnT signal is also output at the start of each SBF transmission. Wake-up signal frame Synch break field Synch field Ident field DATA field Note 2 13 bits SF reception ID reception Data transmission DATA field Check SUM field LIN-bus RXDDn (input) Disable Enable Data Note 5 transmission Data transmission SBF reception Note 3 Reception interrupt (INTUDnR) Note 1 Edge detection Note 4 Capture timer Figure 15-3 Note Disable Enable LIN reception manipulation outline 1. The wakeup signal is sent by the pin edge detector, UARTDn is enabled, and the SBF reception mode is set. 2. Upon detection of the SBF reception of 11 or more bits, normal SBF reception end is judged. When the SBF reception mode selection bit (UDnSRS) is set to "0", the receive completion interrupt request signal (INTUDnR) is generated, and when the UDnSRS is set to "1", the status interrupt request signal (INTUDnS) is generated. Upon detection of SBF reception of less than 11 bits, an SBF reception error is judged, no interrupt signal is output, and the mode returns to the SBF reception mode. 3. When SBF reception ends normally, if the SBF reception mode selection bit (UDnSRS) is "0", the receive completion interrupt request signal (INTUDnR) is generated, and if the UDnSRS is "1", the status interrupt request signal (INTUDnS) is generated and the SBF reception success flag (UDnSSF) is set. If the SBF reception trigger bit (UDnSRT) is "1", the error detection for the overrun, parity, and framing (UDnOVE, UDnPE, UDnFE) is not performed during the SBF reception. Moreover, the data transfer from the receive shift register to the receive data register (UDnRX) is not performed, either. At this time, the UDnRX holds the prior value. 4. The RXDDn pin is connected to TI (capture input) of the timer, the transfer rate is calculated, and the baud rate error is calculated. The value of the UDnCTL2 register obtained by correcting the baud rate error after dropping UARTD enable is set again, causing the status to become the reception status. User's Manual U18743EE1V2UM00 407 Chapter 15 Asynchronous Serial Interface (UARTD) 5. Check-sum field distinctions are made by software. UARTDn is initialized following CSF reception, and the processing for setting the SBF reception mode again is performed by software. When the UDnSRS bit = 1, the SBF reception can be performed automatically without setting to the SBF reception mode again. 15.5.3 SBF transmission When the UDnCTL0.UDnPWR bit = UDnCTL0.UDnTXE bit = 1, the transmission enabled status is entered, and SBF transmission is started by setting (to 1) the SBF transmission trigger (UDnOPT0.UDnSTT bit). Thereafter, a low level the width of bits 13 to 20 specified by the UDnOPT0.UDnSLS2 to UDnOPT0.UDnSLS0 bits is output. A transmission enable interrupt request signal (INTUDnT) is generated upon SBF transmission start. Following the end of SBF transmission, the UDnSTT bit is automatically cleared. Thereafter, the UART transmission mode is restored. Transmission is suspended until the data to be transmitted next is written to the UDnTX register, or until the SBF transmission trigger (UDnSTT bit) is set. 1 2 3 4 5 6 7 8 9 10 11 12 13 Stop bit INTUDnT interrupt UDnTSF Setting of UAnSTT bit Figure 15-4 SBF transmission 15.5.4 SBF reception The reception enabled status is achieved by setting the UDnCTL0.UDnPWR bit to 1 and then setting the UDnCTL0.UDnRX bit to 1. The SBF reception wait status is set by setting the SBF reception trigger (UDnOPT0.UDnSTR bit) to 1. In the SBF reception wait status, similarly to the UART reception wait status, the RXDDn pin is monitored and start bit detection is performed. Following detection of the low level, reception is started and the internal counter counts up according to the set baud rate. When a high level is received and if the SBF width is 11 or more bits, when SBF receiving mode selection bit (UDnSRS) is "0" the reception completion interrupt request signal (INTUDnR) is generated. When the UDnSRS bit is "1" the SBF reception success flag (UDnSSF) is set at the same time as generating a status interrupt request signal (INTUDnS). The UDnOPT0.UDnSRF bit is automatically cleared and SBF reception ends. Error detection for the UDnSTR.UDnOVE, UDnSTR.UDnPE, and UDnSTR.UDnFE 408 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Chapter 15 bits is suppressed and UART communication error detection processing is not performed. Moreover, data transfer of the UARTDn reception shift register and UDnRX register is not performed and FFH, the initial value, is held. If the SBF width is 10 or fewer bits, reception is terminated as error processing without outputting an interrupt, and the SBF reception mode is returned to. The UDnSRF bit is not cleared at this time. The SBF mode can be selected between a single SBF receive mode and an any time SBF receive mode in the UDnOPT1 register (UDnOPT1.UDnSRS). The status of a successful reception of the SBF is shown y the UDnOPT1.UDnSRS bit in the UDnOPT1 register. (a) Normal SBF reception (detection of stop bit in more than 10.5 bits) 1 2 3 4 5 6 7 8 9 10 11 11.5 UDnSRF INTUDnR interrupt (b) SBF reception error (detection of stop bit in 10.5 or fewer bits) 1 2 3 4 5 6 7 8 9 10 10.5 UD0SRF INTUDnR interrupt Note The UDnSRF bit is reset by setting the UDnSRT bit to "1", and cleared by normal SBF reception. User's Manual U18743EE1V2UM00 409 Chapter 15 Asynchronous Serial Interface (UARTD) 15.5.5 Data consistency check The UARTD incorporates a data consistency check function to detect a mismatch between the transmit data written to transmit register (UDnTX) and the data on the bus when the device operates in master mode. The data consistency is checked by comparing the transmit data in the transmit register (UDnTX) and the receive data in the receive register (UDnRX). In case of a mismatch the data consistency error flag (UDnSTR.UDnDCE) is set and a status interrupt request (INTUDnS) occurs. The consistency check of the send data and the input data terminal level is done even if the reception is disabled (UDnRXE = 0) during sending. In that case also the reception completion interrupt request signal (INTUDnR), the UDnSSF, UDnFE, UDnOVE and the status interrupt request signal (INTUDnS) will not be generated as well. Receive data does not need to be read. Refer to "UARTDn status register (UDnSTR)" on page 393 for details. (a) Timing example of data consistency error (UDnSRF = 0) Communication stops UDnTX signal Start bit D0 D1 D2 D3 D4 D5 D6 D7 Stop bit UDnRX signal Start bit D0 D1 D2 D3 D4 D5 D6 D7 Stop bit UDnSTR. UDnTSF Mismatch detection internal error detection UDnSTR. UDnDCE INTUDnS 410 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Chapter 15 (b) Timing example of data consistency error when there is a delay between transmit and receive operation Communication stops UDnTX signal 0xD5 UDnRX signal 0xAA Start bit Start bit D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7 Stop bit UDnSTR. UDnTSF Stop bit Reception end internal error detection UDnSTR. UDnDCE INTUDnS User's Manual U18743EE1V2UM00 411 Chapter 15 Asynchronous Serial Interface (UARTD) 15.5.6 UART transmission First, set the transmission enabled status by performing the following procedures. * Specify the operation clock by the UARTD control register 1 (UDnCTL1) * Specify the baud rate by the UARTD control register 2 (UDnCTL2) * Specify the output logic level by the UARTD option control register 0 (UDnOPT0). * Specify the transmit destination, parity, data character length, stop bit length by the UARTD control register 0 (UDnCTL0). * Set the power bit and the transmission enabled bit (UDnPWR = 1, UDnTXE = 1) Write of the transmit data to the transmission buffer register (UDnTX) starts transmission. The data which is saved in the UDnTX register is transferred to the transmit shift register (UDnTXS). Then, the start bit, parity bit, and stop bit are added and the data is output serially from the TXDDn to the data. Moreover, at the timing that the transfer to UDnTXS of the data stored in UDnTX is completed, a transmission interrupt request signal (INTUDnT) is generated. Once INTUDnT is generated, the next data can be written to UDnTX. Start bit D0 D1 D2 D3 INTUDnT Note 412 LSB first User's Manual U18743EE1V2UM00 D4 D5 D6 D7 Parity Stop bit bit Asynchronous Serial Interface (UARTD) Chapter 15 15.5.7 Continuous transmission procedure UARTDn can write the next transmit data to the UDnTX register when the UARTDn transmit shift register starts the shift operation. The transmit timing of the UARTDn transmit shift register can be judged from the transmission enable interrupt request signal (INTUDnT). An efficient communication rate is realized by writing the data to be transmitted next to the UDnTX register during transfer. Caution During continuous transmission execution, perform initialization after checking that the UDnSTR.UDnTSF bit is 0. The transmit data cannot be guaranteed when initialization is performed while the UDnTSF bit is 1. Start Register settings UDnTX write Occurrence of transmission interrupt? No Yes Required number of writes performed? No Yes End Figure 15-5 Continuous transmission processing flow User's Manual U18743EE1V2UM00 413 Chapter 15 Asynchronous Serial Interface (UARTD) Start TXDDn UDnTX Data (1) Parity Data (1) Transmission shift register Stop Start Data (2) Parity Data (2) Stop Start Data (3) Data (2) Data (1) INTUDnT UDnTSF Figure 15-6 UDTTXD Parity UDnTX Continuous transmission operation timing --transmission start Stop Start Data (n - 1) Parity Data (n - 1) Transmission shift register Stop Start Data (n) Parity Stop Data (n) Data (n - 1) Data (n) FF INTUDnT UDnTSF UDnPWR or UDnTXE bit Figure 15-7 Continuous transmission operation timing--transmission end 15.5.8 UART reception First, set the reception enabled status by the next operations to monitor the RXDDn input and perform the start bit detection. * Specify the operation clock by the UARTD control register 1 (UDnCTL1) * Specify the baud rate by the UARTD control register 2 (UDnCTL2) * Specify the output logic level by the UARTD option control register 0 (UDnOPT0) 414 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Chapter 15 * Specify the communication direction, parity, data character length, and stop bit length by the UARTD control register 0 (UDnCTL0). * Set the power bit and the reception enabled bit (UDnPWR = 1, UDnRXE = 1). When the sampling of the input level of the RXDDn pin is performed and the falling edge is detected, the data sampling of the RXDDn input is started. The start bit is recognized if the RXDDn pin is low level after the time of a half bit is passed after the detection of the falling edge (shown in the figure below). After a start bit has been recognized, the receive operation starts, and serial data is stored in the receive shift register according to the set baud rate. When the reception complete interrupt request signal (INTUDnR) is output upon reception of the stop bit, the data stored in the receive shift register is written to the receive data register (UDnRX). However, if an overrun error occurs (UDnOVE = 1), the receive data at this time is not transferred to the UDnRX register and is discarded. Even if a parity error (UDnPE = 1) or a framing error (UDnFE = 1) occurs during reception, reception continues until the reception position of the first stop bit, and the reception data is transferred to the UDnRX. In any case of the reception errors, INTUDnS is output after the following reception completion, but not INTUDnR. when the communication direction, parity, data character length, and the stop bit length are changed, clear the power bit (UDnPWR = 0) or clear both the transmission enabled bit and the reception enabled bit (UDnTXE = 0, UDnRXE = 0), and then change the setting. Start bit D0 D1 D2 D3 D4 D5 D6 D7 Parity Stop bit bit INTUDnR UDnRX Figure 15-8 Caution UART reception 1. Be sure to read the UDnRX register even when a reception error occurs. If the UDnRX register is not read, an overrun error occurs during reception of the next data. 2. The operation during reception is performed assuming that there is only one stop bit. A second stop bit is ignored. 3. When reception is completed, read the UDnRX register after the reception complete interrupt request signal (INTUDnR) has been generated, and clear the UDnPWR or UDnRXE bit to 0. If the UDnPWR or UDnRXE bit is cleared to 0 before the INTUDnR signal is generated, the read value of the UDnRX register cannot be guaranteed. 4. If receive completion processing (INTUDnR signal generation) of UARTDn User's Manual U18743EE1V2UM00 415 Chapter 15 Asynchronous Serial Interface (UARTD) and the UDnPWR bit = 0 or UDnRXE bit = 0 conflict, the INTUDnR signal may be generated in spite of these being no data stored in the UDnRX register. To complete reception without waiting INTUDnR signal generation, be sure to clear (0) the interrupt request flag (UDnRIF) of the UDnRIC register, after setting (1) the interrupt mask flag (UDnRMK) of the interrupt control register (UDnRIC) and then set (1) the UDnPWR bit = 0 or UDnRXE bit = 0. Note 1. If the low level is always input to the RXDDn pin, it is not judged as the start bit. 2. In continuous reception, immediately after the stop bit is detected at the first reception bit (when the reception completion interrupt is generated), the next start bit can be detected. 3. If the UDnRDL = 1 (receive data inversion input) is selected, when the reception is started, change the data reception pin to the UART receive pin mode and then enable the reception. If the pin mode is changed after the reception is enabled, the start bit is detected faultily if the pin level at this time is high level. 15.5.9 Reception errors Errors during a receive operation are of three types: parity errors, framing errors, and overrun errors. Data reception result error flags are set in the UDnSTR register and a status interrupt request signal INTUDnS is output when an error occurs. It is possible to ascertain which error occurred during reception by reading the contents of the UDnSTR register. Clear the reception error flag by writing 0 to it after reading it. Table 15-2 Reception error causes Error flag Reception error Cause UDnPE Parity error Received parity bit does not match the setting UDnFE Framing error Stop bit not detected UDnOVE Overrun error Reception of next data completed before data was read from receive buffer Note Note that even in case of a parity or framing error, data is transferred from the receive shift register to the receive data register UDnRX. Consequently the data from UDnRX must be read. Otherwise an overrun error UDnSTR.UDnOVE will occur at reception of the next data. In case of an overrun error, the receive shift register data is not transferred to UDnRX, thus the previous data is not overwritten. 15.5.10 Parity types and operations Caution 416 When using the LIN function, fix the UDnPS1 and UDnPS0 bits of the UDnCTL0 register to 00. User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Chapter 15 The parity bit is used to detect bit errors in the communication data. Normally the same parity is used on the transmission side and the reception side. In the case of even parity and odd parity, it is possible to detect odd-count bit errors. In the case of 0 parity and no parity, errors cannot be detected. (1) Even parity * During transmission The number of bits whose value is "1" among the transmit data, including the parity bit, is controlled so as to be an even number. The parity bit values are as follows. - Odd number of bits whose value is "1" among transmit data:1 - Even number of bits whose value is "1" among transmit data:0 * During reception The number of bits whose value is "1" among the reception data, including the parity bit, is counted, and if it is an odd number, a parity error is output. (2) Odd parity * During transmission Opposite to even parity, the number of bits whose value is "1" among the transmit data, including the parity bit, is controlled so that it is an odd number. The parity bit values are as follows. - Odd number of bits whose value is "1" among transmit data: 0 - Even number of bits whose value is "1" among transmit data: 1 * During reception The number of bits whose value is "1" among the receive data, including the parity bit, is counted, and if it is an even number, a parity error is output. (3) 0 parity During transmission, the parity bit is always made 0, regardless of the transmit data. During reception, parity bit check is not performed. Therefore, no parity error occurs, regardless of whether the parity bit is 0 or 1. (4) No parity No parity bit is added to the transmit data. Reception is performed assuming that there is no parity bit. No parity error occurs since there is no parity bit. User's Manual U18743EE1V2UM00 417 Chapter 15 Asynchronous Serial Interface (UARTD) 15.5.11 Receive data noise filter This filter samples the RXDDn pin using the base clock of the prescaler output. When the same sampling value is read twice, the match detector output changes and the RXDDn signal is sampled as the input data. Therefore, data not exceeding 2 clock width is judged to be noise and is not delivered to the internal circuit (see Figure 15-10). See "Base clock" on page 419 regarding the base clock. Moreover, since the circuit is as shown in Figure 15-9, the processing that goes on within the receive operation is delayed by 3 clocks in relation to the external signal status. Base clock (fUCLK) RXDAn In Q Internal signal A In Q Internal signal B Match detector Figure 15-9 In Q Internal signal C LD_EN Noise filter circuit Base clock RXDDn (input) Internal signal A Internal signal B Match Mismatch (judged as noise) Internal signal C Figure 15-10 418 Timing of RXDDn signal judged as noise User's Manual U18743EE1V2UM00 Match Mismatch (judged as noise) Asynchronous Serial Interface (UARTD) Chapter 15 15.6 Baud Rate Generator The dedicated baud rate generator consists of a source clock selector block and an 8-bit programmable counter, and generates a serial clock during transmission and reception with UARTDn. Regarding the serial clock, a dedicated baud rate generator output can be selected for each channel. There is an 8-bit counter for transmission and another one for reception. (1) Baud rate generator configuration UDnPWR UDnPWR, UDnTXEn bit (or UDnRXE bit) fXP1 or fXP2 fXP1/2 8-bit counter fXP1/4 fUCLK Selector ... fXP1/1024 ASCKD0Note Match detector UDnCTL1: UDnCKS3 to UDnCKS0 1/2 Baud rate UDnCTL2: UDnBRS7 to UDnBRS0 Note: External clock ASCKD0 is only availabel for UARTD0 Figure 15-11 Configuration of baud rate generator (a) Base clock When the UDnCTL0.UDnPWR bit is 1, the clock selected by the UDnCTL1.UDnCKS[3:0] bits are supplied to the 8-bit counter. This clock is called the base clock. When the UDnPWR bit = 0, fUCLK is fixed to the low level. (b) Serial clock generation A serial clock can be generated by setting the UDnCTL1 register and the UDnCTL2 register. The base clock is selected by UDnCTL1.UDnCKS3 to UDnCTL1.UDnCKS0 bits. The frequency division value for the 8-bit counter can be set using the UDnCTL2.UDnBRS[7:0] bits. User's Manual U18743EE1V2UM00 419 Chapter 15 Asynchronous Serial Interface (UARTD) (2) UDnCTL1 - UARTDn control register 1 The UDnCTL1 register is an 8-bit register that selects the UARTDn base clock. This register can be read or written in 8-bit units. Reset input clears this register to 00H. Caution Clear the UDnCTL0.UDnPWR bit to 0 before rewriting the UDnCTL1 register. After reset: 00H Address: UD0CTL1: FFFFFA01, UD1CTL1: FFFFFA11 UD2CTL1: FFFFFA21 7 6 5 4 UDnCTL1 0 0 0 0 R/W R R R R SELCNTm registera ISELn 3 R/W UDnCKS1 UDnCKS0 R/W R/W Input PRSI = 0 PRSI = 1 0 0 0 0 fXP1 fXX fXX/2 fXP2b fXX fXX/2 X 0 0 0 1 fXP1/2 fXX/2 fXX/4 X 0 0 1 0 fXP1/4 fXX/4 fXX/8 X 0 0 1 1 fXP1/8 fXX/8 fXX/16 X 0 1 0 0 fXP1/16 fXX/16 fXX/32 X 0 1 0 1 fXP1/32 fXX/32 fXX/64 X 0 1 1 0 fXP164 fXX/64 fXX/128 X 0 1 1 1 fXP1/128 fXX/128 fXX/256 X 1 0 0 0 fXP1/256 fXX/256 fXX/512 X 1 0 0 1 fXP1/512 fXX/512 fXX/1024 X 1 0 1 0 fXP1/1024 fXX/1024 fXX/2048 X 1 0 1 1 - ASCKA0c - Setting prohibited For detailed information concerning the SELCNTm register refer to "Clock Generator" on page 179. fXP2 has hte same frequency as fXP1, but does not stop in IDLE1 mode. ASCKD0 is an external clock only for UARTD0. For UARTD1-5 the setting is prohibited. Note PRSI can be set by the option bytes: Refer to "Flash Memory" on page 259 for details. 420 0 Input clock (fCLK) Other than above c) R/W UDnCTL1 register UDnCKS2 1 a) 1 UDnCKS3 UDnCKS2 UDnCKS1 UDnCKS0 UDnCKS3 0 b) 2 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) (3) Chapter 15 UDnCTL2 - UARTDn control register 2 The UDnCTL2 register is an 8-bit register that selects the baud rate (serial transfer speed) clock of UARTDn. This register can be read or written in 8-bit units. Reset input sets this register to FFH. Caution Clear the UDnCTL0.UDnPWR bit to 0 or clear the UDnTXE and UDnRXE bits to 00 before rewriting the UDnCTL2 register. After reset FFH R/W 6 7 UDnCTL2 Note (4) Address: UD0CTL2 FFFFFA02H, UD1CTL2 FFFFFA12H, UD2CTL2 FFFFFA22H 5 4 3 2 1 0 UDnBRS7 UDnBRS6 UDnBRS5 UDnBRS4 UDnBRS3 UDnBRS2 UDnBRS1 UDnBRS0 UDn BRS7 UDn BRS6 UDn BRS5 UDn BRS4 UDn BRS3 UDn BRS2 UDn BRS1 0 0 0 0 0 0 x x x Setting prohibited 0 0 0 0 0 1 0 0 4 fUCLK/4 0 0 0 0 0 1 0 1 5 fUCLK/5 0 0 0 0 0 1 1 0 6 fUCLK/6 : : : : : : : : : : 1 1 1 1 1 1 0 0 252 fUCLK/252 1 1 1 1 1 1 0 1 253 fUCLK/253 1 1 1 1 1 1 1 0 254 fUCLK/254 1 1 1 1 1 1 1 1 255 fUCLK/255 UDn Default BRS0 (k) Serial clock fUCLK: Clock frequency selected by UDnCTL1.UDnCKS[3:0] Baud rate The baud rate is obtained by the following equation. fUCLK - [bps] Baud rate = -------------2xk fUCLK = frequency of base clock selected by the UDnCTL1.UDnCKS[3:0]. k = Value set using the UDnCTL2.UDnBRS[7:0] bits (k = 4, 5, 6, ..., 255) User's Manual U18743EE1V2UM00 421 Chapter 15 Asynchronous Serial Interface (UARTD) (5) Baud rate error The baud rate error is obtained by the following equation. Error (%) = Caution baud rate (baud rate with error) --------------------------------------------------------------------------- - 1 ) x 100 [%] ( Actual Target baud rate (correct baud rate) 1. The baud rate error during transmission must be within the error tolerance on the receiving side. 2. The baud rate error during reception must satisfy the range indicated in (7) Allowable baud rate range during reception. Example * Base clock frequency fxx = 20 MHz * Setting value of - PRSI = 0: fXP1 = fxx = 20MHz - UDnCTL1.UDnCKS[3:0] = 0001B: fUCLK = fXP1/2 = 10 MHz - UDnCTL2.UDnBRS[7:0] = 0011 0100B: k = 52 * Target baud rate = 153,600 bps * Actual Baud rate = 10 MHz / (2 x 52) = 153,846 [bps] * Baud rate error = (153,846/153,600 - 1) x 100 = 0.160 [%] (6) Table 15-3 Target baud rate [bps] Baud rate setting example Baud rate generator setting data (normal operation, fXP1 = 20 MHz, PRSI = 0) UDnCTL1 UDnCTL2 Baud rate error (%) Selector Divider 300 08H 256 82H 130 300.48 0.16 600 08H 256 41H 65 600.96 0.16 1,200 07H 128 41H 65 1,201.92 0.16 2,400 06H 64 41H 65 2,403.85 0.16 4,800 05H 32 41H 65 4,807.69 0.16 9,600 04H 16 41H 65 9,615.38 0.16 19,200 03H 8 41H 65 19,230.77 0.16 31,250 02H 4 50H 80 31,250.00 0.00 38,400 02H 4 41H 65 38,461.54 0.16 76,800 01H 2 41H 65 76,923.08 0.16 153,600 00H 1 41H 65 153,846.15 0.16 312,500 00H 1 20H 32 312.500 0.0 422 Divider k Actual baud rate [bps] User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Table 15-4 Target baud rate [bps] Chapter 15 Baud rate generator setting data (normal operation, fXP1 = 16 MHz, PRSI = 0) UDnCTL1 UDnCTL2 Divider k Actual baud rate [bps] Baud rate error (%) Selector Divider 300 08H 256 68H 104 300.48 0.16 600 08H 256 34H 52 600.96 0.16 1,200 07H 128 34H 52 1,201.92 0.16 2,400 06H 64 34H 52 2,403.85 0.16 4,800 05H 32 34H 52 4,807.69 0.16 9,600 04H 16 34H 52 9,615.38 0.16 19,200 03H 8 34H 52 19,230.77 0.16 31,250 03H 8 20H 32 31,250.00 0.00 38,400 02H 4 34H 52 38,461.54 0.16 76,800 01H 2 34H 52 76,923.08 0.16 153,600 00H 1 34H 52 153,846.15 0.16 312,500 00H 1 1AH 26 307,692.31 -1.54 User's Manual U18743EE1V2UM00 423 Chapter 15 Asynchronous Serial Interface (UARTD) (7) Allowable baud rate range during reception The baud rate error range at the destination that is allowable during reception is shown below. Caution The baud rate error during reception must be set within the allowable error range using the following equation. Latch timing UARTn transfer rate Start bit Bit 0 Bit 1 Bit 7 Parity bit Stop bit FL 1 data frame (11 x FL) Minimum allowable transfer rate Start bit Bit 0 Bit 1 Bit 7 Parity bit Stop bit FLmin Maximum allowable transfer rate Start bit Bit 0 Bit 1 Bit 7 Parity bit Stop bit FLmax Figure 15-12 Allowable baud rate range during reception As shown in Figure 15-12, the receive data latch timing is determined by the counter set using the UDnCTL2 register following start bit detection. The transmit data can be normally received if up to the last data (stop bit) can be received in time for this latch timing. When this is applied to 11-bit reception, the following is the theoretical result. FL = (Brate)-1 Brate:UARTDn baud rate k: Setting value of UDnCTL2.UDnBRS[7:0] FL: 1-bit data length Latch timing margin: 2 clocks Minimum allowable transfer rate: 21k + 2 k-2 FL min = 11 x FL - ------------ x FL = ------------------- x FL 2k 2k Therefore, the maximum baud rate that can be received by the destination is as follows. BRmax = ( FLmin 11 ) 424 -1 22k = ------------------- x Brate 21k + 2 User's Manual U18743EE1V2UM00 Asynchronous Serial Interface (UARTD) Chapter 15 Similarly, obtaining the following maximum allowable transfer rate yields the following. 1021k - 2 k+2 ----x FLmax = 11 x FL - ------------ x FL = ------------------- x FL 11 2k 2k 21k - 2 FLmax = ------------------- x FL x 11 20k Therefore, the minimum baud rate that can be received by the destination is as follows. BRmin = ( FLmax 11 ) -1 20k = ------------------- x Brate 21k - 2 Obtaining the allowable baud rate error for UARTDn and the destination from the above-described equations for obtaining the minimum and maximum baud rate values yields the following. Table 15-5 Maximum/Minimum allowable baud rate error Division ratio (k) Maximum allowable baud rate error Minimum allowable baud rate error 4 +2.32% -2.43% 8 +3.52% -3.61% 20 +4.26% -4.30% 50 +4.56% -4.58% 100 +4.66% -4.67% 255 +4.72% -4.72% Note 1. The reception accuracy depends on the bit count in 1 frame, the input clock frequency, and the division ratio (k). The higher the input clock frequency and the larger the division ratio (k), the higher the accuracy. 2. k: Setting value of UDnCTL2.UDnBRS[7:0] User's Manual U18743EE1V2UM00 425 Chapter 15 Asynchronous Serial Interface (UARTD) (8) Baud rate during continuous transmission During continuous transmission, the transfer rate from the stop bit to the next start bit is usually 2 base clocks longer. However, timing initialization is performed via start bit detection by the receiving side, so this has no influence on the transfer result. Start bit of 2nd byte 1 data frame Start bit Bit 0 Bit 1 Bit 7 FL FL FL FL Figure 15-13 Parity bit Stop bit FL FLstp Start bit FL Bit 0 FL Transfer rate during continuous transfer Assuming 1 bit data length: FL; stop bit length: FLstp; and base clock frequency: fUCLK, we obtain the following equation. FLstp = FL + 2/fUCLK Therefore, the transfer rate during continuous transmission is as follows. Transfer rate = 11 x FL + (2/fUCLK) 15.7 Cautions When the clock supply to UARTDn is stopped (for example, in IDLE1, IDLE2, or STOP mode), the operation stops with each register retaining the value it had immediately before the clock supply was stopped. The TXDDn pin output also holds and outputs the value it had immediately before the clock supply was stopped. However, the operation is not guaranteed after the clock supply is resumed. Therefore, after the clock supply is resumed, the circuits should be initialized by setting the UDnCTL0.UDnPWR, UDnCTL0.UDnRXEn, and UDnCTL0.UDnTXEn bits to 000. 426 User's Manual U18743EE1V2UM00 Chapter 16 Clocked Serial Interface (CSIB) The V850ES/Fx3-L microcontrollers have following instances of the Clocked Serial Interface CSIB: CSIB V850ES/FE3-L V850ES/FF3-L Instances V850ES/FG3-L 2 Names CSIB0 to CSIB1 Throughout this chapter, the individual instances of CSIB are identified by "n", for example, CBnCTL0 for the CSIBn control register 0. 16.1 Features * Transfer rate: 8 Mbps to 2 Kbps (using dedicated baud rate generator) * Master mode and slave mode selectable * 8-bit to 16-bit transfer, 3-wire serial interface * 2 interrupt request signals (INTCBnT and INTCBnR) * Serial clock and data phase switchable * Transfer data length selectable in 1-bit units between 8 and 16 bits * Transfer data MSB-first/LSB-first switchable * 3-wire transfer SOBn: SIBn: SCKBn: Serial data output Serial data input Serial clock input/output Transmission mode, reception mode, and transmission/reception mode specifiable * Baud rate generator input for CSIB0 User's Manual U18743EE1V2UM00 427 Chapter 16 Clocked Serial Interface (CSIB) 16.2 Configuration The following shows the block diagram of CSIBn. Internal bus CBnCTL1 CBnCTL0 CBnCTL2 CBnSTR INTCBnT INTCBnR Controller Selector fXP1/2 fXP1/4 fXP1/8 fXP1/16 fXP1/32 fXP1/64 fBRG (n=0) or TOAA01(n=1) or fXP1/128(n=2,3) Phase control CBnTX SCKBn SO latch SIBn Shift register Phase control SOBn CBnRX Figure 16-1 Note Block diagram of CSIBn For details on the setting of fCK refer to "CBnCTL1 - CSIBn control register 1" on page 432. CSIBn includes the following hardware. Table 16-1 428 Configuration of CSIBn Item Configuration Registers CSIBn receive data register (CBnRX) CSIBn transmit data register (CBnTX) Control registers CSIBn control register 0 (CBnCTL0) CSIBn control register 1 (CBnCTL1) CSIBn control register 2 (CBnCTL2) CSIBn status register (CBnSTR) User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) (1) Chapter 16 CBnRX - CSIBn receive data register The CBnRX register is a 16-bit buffer register that holds receive data. This register is read-only, in 16-bit units. The receive operation is started by reading the CBnRX register in the reception enabled status. If the transfer data length is 8 bits, the lower 8 bits of this register are read-only in 8-bit units as the CBnRXL register. Reset input clears this register to 0000H. In addition to reset input, the CBnRX register can be initialized by clearing (to 0) the CBnPWR bit of the CBnCTL0 register. After reset: 0000H R Address : CB0RX FFFFFD04H, CB1RX FFFFFD14H, CBnRX (2) CBnTX - CSIB transmit data register The CBnTX register is a 16-bit buffer register used to write the CSIBn transfer data. This register can be read or written in 16-bit units. The transmit operation is started by writing data to the CBnTX register in the transmission enabled status. If the transfer data length is 8 bits, the lower 8 bits of this register are read/write in 8-bit units as the CBnTXL register. Reset input clears this register to 0000H. In addition to reset input, the CBnTX register can be initialized by clearing the CBnPWR bit of the CBnCTL0 register. After reset 0000H R/W Address : CB0TX FFFFFD06H, CB1TX FFFFFD16H CBnTX Note The communication start conditions are shown below: * Transmission mode (CBnTXE bit = 1, CBnRXE bit = 0): Write to CBnTX register * Transmission/reception mode (CBnTXE bit = 1, CBnRXE bit = 1): Write to CBnTX register * Reception mode (CBnTXE bit = 0, CBnRXE bit = 1): Read from CBnRX register User's Manual U18743EE1V2UM00 429 Chapter 16 Clocked Serial Interface (CSIB) 16.3 CSIB Control Registers The following registers are used to control CSIBn. * CSIBn control register 0 (CBnCTL0) * CSIBn control register 1 (CBnCTL1) * CSIBn control register 2 (CBnCTL2) * CSIBn status register (CBnSTR) (1) CBnCTL0 - CSIBn control register 0 CBnCTL0 is a register that controls the CSIBn serial transfer operation. This register can be read or written in 8-bit or 1-bit units. Reset input sets this register to 01H. . After reset: 04H 7 UDnOPT0 CBnPWR R/W R/W Address: CB0CTL0: FFFFFD00, CB1CTL0: FFFFFD10 CB2CTL0: FFFFFD20, CB2CTL0: FFFFFD30 6 5 4 CBnTXE CBnRXE CBnDIR Note1 Note1 R/W R/W CBnPWR 3 2 Note1 0 0 R/W R R 1 CBnTWS 0 Note1 CBnSCE R/W R/W Specification of CSIBn operation disable/enable 0 Disable CSIBn operation and reset the CBnSTR register. 1 Enable CSIBn operation. The CBnPWR bit controls the CSIBn operation and resets the internal circuit. CBnTXE Specification of transmit operation disable/enable 0 Disable transmit operation 1 Enable transmit operation The SOBn output is low level and transmission is disabled when the CBnTXE bit is 0. CBnRXE Specification of transmit operation disable/enable 0 Disable receive operation 1 Enable receive operation * When the CBnRXE bit is cleared to 0, no reception complete interrupt is output even when the prescribed data is transferred in order to disable the receive operation, and the receive data (CBnRX register) is not updated. CBnDIR Specification of transfer direction mode (MSB/LSB) 0 MSB first 1 LSB first CBnTMS 430 Transfer mode specification 0 Single transfer mode 1 Continuous transfer mode User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) CBnSCE Chapter 16 Specification of start transfer disable/enable 0 Reception start trigger invalid 1 Recepetion start trigger valid This bit controls the behaviour upon a communication start trigger in master/slave single/continuous reception mode. To start the reception operation set the bit to 1 before performing a dummy read to the CBnRX register. To stop the reception operation in * Single reception mode clear the CBnSCE bit before reading the final data from the CBnRX register. * Continuous reception mode clear the CBnSCE bit at least one communication clock before the completion of the last data reception. For details refer to chapter 16.4"Operation" on page 436. Note 1. These bits can only be rewritten when the CBnPWR bit = 0. However, the CBnPWR can be set to 1 at the same time as these bits are rewritten. 2. To abort reception/transmission forcibly, clear the CBnPWR bit (not the CBnTXE bit or CBnRXE bit) to 0. The clock output stops at this time. User's Manual U18743EE1V2UM00 431 Chapter 16 Clocked Serial Interface (CSIB) (2) CBnCTL1 - CSIBn control register 1 CBnCTL1 is an 8-bit register that controls the CSIBn serial transfer operation. This register can be read or written in 8-bit units. Reset input clears this register to 00H. Caution The CBnCTL1 register can be rewritten only when the CBnCTL0.CBnPWR bit = 0. After reset 00H CBnCTL1 R/W 0 Address : CB0CTL1 FFFFFD01H, CB1CTL1 FFFFFD11H, 0 CBnCKP CBnDAP CBnCKS2 CBnCKS1 CBnCKS0 0 Specification of data transmission/ reception timing in relation to SCKBn CBnCKP CBnDAP Communication type 1 0 0 SCKBn (I/O) D7 SOBn (output) D6 D5 D4 D3 D2 D1 D0 SIBn capture Communication type 2 0 1 SCKBn (I/O) D7 SOBn (output) D6 D5 D4 D3 D2 D1 D0 SIBn capture Communication type 3 1 0 SCKBn (I/O) D7 (output) D6 D5 D4 D3 D2 D1 D0 SIBn capture Communication type 4 1 1 SCKBn (I/O) D7 (output) D6 D5 D4 D3 D2 D1 D0 SIBn capture Input clock CBn CBn CBn CKS2 CKS1 CKS0 Input n=0 PRSI = 0 0 0 0 0 c) d) 432 1 1 1 0 0 1 1 fxx/2 fxx/4 fxx/2 fxx/4 M fXP1 /4b fxx/4 fxx/8 fxx/4 fxx/8 M fXP1 /8b fxx/8 fxx/16 fxx/8 fxx/16 M fxx/16 fxx/32 fxx/16 fxx/32 M fxx/32 fxx/64 fxx/32 fxx/64 M fxx/64 fxx/128 fxx/64 fxx/128 M b fXP1/32b fXP1/64b fBRGc d 1 1 fXP1 fXP1/16 0 0 1 PRSI = 1 PRSI = 0 PRSI = 1 /2b 1 0 1 b) 0 0 1 1 a) 0 Modea n=1 fBRG - M TOAA01 - TOAA01 M fXP1/128 - - M External clock SCKBn M: master mode; S: slave mode Do not use the CSIBn if fXP1 = fRH (high speed internal oscillator clock) The baud rate generator output is also used for the Watch Timer. Output of TAA0 User's Manual U18743EE1V2UM00 S Clocked Serial Interface (CSIB) Note Chapter 16 PRSI can be set by the option bytes: Refer to "Flash Memory" on page 259 for details. (3) CBnCTL2 - CSIBn control register 2 CBnCTL2 is an 8-bit register that controls the number of CSIBn serial transfer bits. This register can be read or written in 8-bit units. Reset input clears this register to 00H. Caution The CBnCTL2 register can be rewritten only when the CBnCTL0.CBnPWR bit = 0 or when both the CBnTXE and CBnRXE bits = 0. After reset: 00H CBnCTL2 0 CBnCL3 Note R/W Address : CB0CTL2 FFFFFD02H, CB1CTL2 FFFFFD12H, 0 0 CBnCL2 CBnCL1 0 CBnCL3 CBnCL2 CBnCL0 CBnCL1 CBnCL0 Serial register bit length 0 0 0 0 8 bits 0 0 0 1 9 bits 0 0 1 0 10 bits 0 0 1 1 11 bits 0 1 0 0 12 bits 0 1 0 1 13 bits 0 1 1 0 14 bits 0 1 1 1 15 bits 1 x x x 16 bits If the number of transfer bits is other than 8 or 16, prepare and use data stuffed from the LSB of the CBnTX and CBnRX registers. User's Manual U18743EE1V2UM00 433 Chapter 16 Clocked Serial Interface (CSIB) Transfer data length change function The CSIBn transfer data length can be set in 1-bit units between 8 and 16 bits using the CBnCTL2.CBnCL3 to CBnCTL2.CBnCL0 bits. When the transfer bit length is set to a value other than 16 bits, set the data to the CBnTX or CBnRX register starting from the LSB, regardless of whether the transfer start bit is the MSB or LSB. Any data can be set for the higher bits that are not used, but the receive data becomes 0 following serial transfer. SOBn SIBn 15 10 9 0 Insertion of 0 Figure 16-2 (i) Transfer bit length = 10 bits, MSB first SIBn 15 12 SOBn 11 Insertion of 0 Figure 16-3 434 (ii) Transfer bit length = 12 bits, LSB first User's Manual U18743EE1V2UM00 0 Clocked Serial Interface (CSIB) (4) Chapter 16 CBnSTR - CSIBn status register CBnSTR is an 8-bit register that displays the CSIBn status. This register can be read or written in 8-bit or 1-bit units, but the CBnTSF flag is read-only. Reset input clears this register to 00H. In addition to reset input, the CBnSTR register can be initialized by clearing (0) the CBnCTL0.CBnPWR bit. After reset 00H R/W Address: CB0STR FFFFFD03H, CB1STR FFFFFD13H < > < > CBnSTR CBnTSF 0 0 CBnTSF 0 0 0 0 CBnOVE Communication status flag 0 Communication stopped 1 Communicating * During transmission, this register is set when data is prepared in the CBnTX register, and during reception, it is set when a dummy read of the CBnRX register is performed. When transfer ends, this flag is cleared to 0 at the last edge of the clock. CBnOVE Overrun error flag 0 No overrun 1 Overrun * An overrun error occurs when the next reception starts without performing a CPU read of the value of the receive buffer, upon completion of the receive operation. The CBnOVE flag displays the overrun error occurrence status in this case. * The CBnOVE flag is cleared by writing 0 to it. It cannot be set even by writing 1 to it. Note In case of an overrun error, the reception interrupt INTCBnR behaves different, depending on the transfer mode: * Continuous transfer mode The reception interrupt INTCBnR is generated. * Single transfer mode No interrupt is generated. In either case the overflow flag CBnSTR.CBnOVE is set to 1 and the previous data in CBnRX will be overwritten with the new data. User's Manual U18743EE1V2UM00 435 Chapter 16 Clocked Serial Interface (CSIB) 16.4 Operation 16.4.1 Single transfer mode (master mode, transmission/reception mode) MSB first (CBnCTL0.CBnDIR bit = 0), communication type 1 (see 16.3 (2) CBnCTL1 - CSIBn control register 1), transfer data length = 8 bits (CBnCTL2.CBnCL3 to CBnCTL2.CBnCL0 bits = 0, 0, 0, 0) CBnTX write (55H) CBnRX read (AAH) SCKBn CBnTX 55H (transmit data) Shift register ABH 56H ADH 5AH B5H 6AH D5H CBnRX AAH 00H AAH 00H INTCBnRNote CBnTSF CBnSCE SIBn 1 0 1 0 1 0 1 0 (AAH) SOBn 0 1 0 1 0 1 0 1 (55H) (1) (2) (3) (4) (5) (6) (7) (8) (1) Clear the CBnCTL0.CBnPWR bit to 0. (2) Set the CBnCTL1 and CBnCTL2 registers to specify the transfer mode. (3) Set the CBnTXE, CBnRXE, and CBnSCE bits of the CBnCTL0 register to 1 at the same time as specifying the transfer mode using the CBnDIR bit, to set the transmission/reception enabled status. (4) Set the CBnPWR bit to 1 to enable the CSIBn operation. (5) Write transfer data to the CBnTX register (transmission start). (6) The reception complete interrupt request signal (INTCBnR) is output. (7) Read the CBnRX register before clearing the CBnPWR bit to 0. (8) Check that the CBnSTR.CBnTSF bit = 0 and set the CBnPWR bit to 0 to stop operation of CSIBn (end of transmission/reception). To continue transfer, repeat steps (5) to (7) before (8). In transmission mode or transmission/reception mode, communication is not started by reading the CBnRX register. 436 User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) Note Chapter 16 1. In single transmission or single transmission/reception mode, the INTCBnT signal is not generated. When communication is complete, the INTCBnR signal is generated. 2. The processing of steps (3) and (4) can be set simultaneously. Caution In case the CSIB interface is operating in * single transmit/reception mode (CBnCTL0.CBnTMS = 0) * communication type 2 respectively type 4 (CBnCTL1.CBnDAP = 1) pay attention to following effect: In case the next transmit should be initiated immediately after the occurrence of the reception completion interrupt INTCBnR any write to the CBnTX register is ignored as long as the communication status flag is still reflecting an ongoing communication (CBnTSF = 1). Thus the new transmission will not be started. For transmitting data continuously use one of the following options: * Use continuous transfer mode (CBnCTL0.CBnTMS = 1). * If single transfer mode (CBnCTL0.CBnTMS = 0) should be used, CBnSTR.CBnTSF = 0 needs to be verified before writing data to the CBnTX register. User's Manual U18743EE1V2UM00 437 Chapter 16 Clocked Serial Interface (CSIB) 16.4.2 Single transfer mode (master mode, reception mode) MSB first (CBnCTL0.CBnDIR bit = 0), communication type 1 (see 16.3 (2) CBnCTL1 - CSIBn control register 1), transfer data length = 8 bits (CBnCTL2.CBnCL3 to CBnCTL2.CBnCL0 bits = 0, 0, 0, 0) CBnRX read (AAH) CBnRX read (55H) SCKBn CBnRX 55H (receive data) Shift register ABH 56H ADH 5AH B5H 6AH D5H AAH 00H AAH 00H INTCBnR 1 SIBn SOBn 0 1 0 1 0 1 0 (AAH) L CBnTSF CBnSCE (1) (5) (2) (3) (4) (6) (7) (8) (9) (1) Clear the CBnCTL0.CBnPWR bit to 0. (2) Set the CBnCTL1 and CBnCTL2 registers to specify the transfer mode. (3) Set the CBnCTL0.CBnRXE and CBnCTL0.CBnSCE bits to 1, CBnCTL0.TXE to 0, at the same time as specifying the transfer mode using the CBnDIR bit, to set the reception enabled status. (4) Set the CBnPWR bit to 1 to enable the CSIBn operation. (5) Perform a dummy read of the CBnRX register (reception start trigger). (6) The reception complete interrupt request signal (INTCBnR) is output. (7) Set the CBnSCE bit to 0 to set the final receive data status. (8) Read the CBnRX register before setting the CBnPWR bit to "0". (9) Check that the CBnSTR.CBnTSF bit = 0 and set the CBnPWR bit to 0 to stop the CSIBn operation (end of reception). To continue transfer, repeat steps (5) and (6) before (7). (At this time, (5) is not a dummy read, but a receive data read combined with the reception trigger.) Note 438 The processing of steps (3) and (4) can be set simultaneously. User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) Chapter 16 16.4.3 Continuous mode (master mode, transmission/reception mode) MSB first (CBnCTL0.CBnDIR bit = 0), communication type 3 (see 16.3 (2) CBnCTL1 - CSIBn control register 1), transfer data length = 8 bits (CBnCTL2.CBnCL3 to CBnCTL2.CBnCL0 bits = 0, 0, 0, 0) CBnTX 55H AAH SCKBn SOBn 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 SIBn 1 1 0 0 1 1 0 0 1 0 0 1 0 1 1 0 INTCBnT INTCBnR CBnTSF CBnSCE CCH Shift register 96H 00H 96H 00H SO latch CBnRX CCH (1) (2) (3) (4) (5) (6) (7) (7) (8) (1) Clear the CBnCTL0.CBnPWR bit to 0. (2) Set the CBnCTL1 and CBnCTL2 registers to specify the transfer mode. (3) Set the CBnTXE, CBnRXE, and CBnSCE bits of the CBnCTL0 register to 1 at the same time as specifying the transfer mode using the CBnDIR bit, to set the transmission/reception enabled status. (4) Set the CBnPWR bit to 1 to enable the CSIBn operation. (5) Write transfer data to the CBnTX register (transmission start). (6) The transmission enable interrupt request signal (INTCBnT) is received and transfer data is written to the CBnTX register. (7) The reception complete interrupt request signal (INTCBnR) is output. Read the CBnRX register before the next receive data arrives or before the CBnPWR bit is cleared to 0. User's Manual U18743EE1V2UM00 439 Chapter 16 Clocked Serial Interface (CSIB) (8) Check that the CBnSTR.CBnTSF bit = 0 and set the CBnPWR bit to 0 to stop the operation of CSIBn (end of transmission/reception). To continue transfer, repeat steps (5) to (7) before (8). In transmission mode or transmission/reception mode, the communication is not started by reading the CBnRX register. 16.4.4 Continuous mode (master mode, reception mode) MSB first (CBnCTL0.CBnDIR bit = 0), communication type 2 (see 16.3 (2) CBnCTL1 - CSIBn control register 1), transfer data length = 8 bits (CBnCTL2.CBnCL3 to CBnCTL2.CBnCL0 bits = 0, 0, 0, 0) SCKBn CBnSCE SIBn SOBn 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 L INTCnR CBnTSF Shift register 55H 55H CBnRX (1) (2) (3) (4) (5) (6) AAH 00H AAH 00H (7) (6) (8) (1) Clear the CBnCTL0.CBnPWR bit to 0. (2) Set the CBnCTL1 and CBnCTL2 registers to specify the transfer mode. (3) Set the CBnCTL0.CBnRXE bit to 1 and specify the transfer mode using the CBnDIR bit, to set the reception enabled status. (4) Set the CBnPWR bit to 1 to enable the CSIBn operation. (5) Perform a dummy read of the CBnRX register (reception start trigger). (6) The reception complete interrupt request signal (INTCBnR) is output. Read the CBnRX register before the next receive data arrives or before the CBnPWR bit is cleared to 0. (7) Set the CBnCTL0.CBnSCE bit = 0 while the last data being received to set the final receive data status. 440 User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) Chapter 16 (8) Check that the CBnSTR.CBnTSF bit = 0 and set the CBnPWR bit to 0 to stop the operation of CSIBn (end of reception). To continue transfer, repeat steps (5) and (6) before (7). 16.4.5 Continuous reception mode (error) MSB first (CBnCTL0.CBnDIR bit = 0), communication type 2 (see 16.3 (2) CBnCTL1 - CSIBn control register 1), transfer data length = 8 bits (CBnCTL2.CBnCL3 to CBnCTL2.CBnCL0 bits = 0, 0, 0, 0) SCKBn SIBn SOBn 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 L INTCBnR CBnTSF Shift register AAH 00H 55H CBnRX 55H AAH 00H CBnOVE (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (1) Clear the CBnCTL0.CBnPWR bit to 0. (2) Set the CBnCTL1 and CBnCTL2 registers to specify the transfer mode. (3) Set the CBnCTL0.CBnRXE bit to 1 at the same time as specifying the transfer mode using the CBnDIR bit, to set the reception enabled status. (4) Set the CBnPWR bit = 1 to enable CSIBn operation. (5) Perform a dummy read of the CBnRX register (reception start trigger). (6) The reception complete interrupt request signal (INTCBnR) is output. (7) If the data could not be read before the end of the next transfer, the CBnSTR.CBnOVE flag is set to 1 upon the end of reception and the reception interrupt INTCBnR is output again. User's Manual U18743EE1V2UM00 441 Chapter 16 Clocked Serial Interface (CSIB) (8) Overrun error processing is performed after checking that the CBnOVE bit = 1 in the INTCBnR interrupt servicing. (9) Clear CBnOVE bit to 0. (10)Check that the CBnSTR.CBnTSF bit = 0 and set the CBnPWR bit to 0 to stop the operation CSIBn (end of reception). 16.4.6 Continuous mode (slave mode, transmission/reception mode) MSB first (CBnCTL0.CBnDIR bit = 0), communication type 2 (see 16.3 (2) CBnCTL1 - CSIBn control register 1), transfer data length = 8 bits (CBnCTL2.CSnCL3 to CBnCTL2.CBnCL0 bits = 0, 0, 0, 0) CBnTX AAH 55H SCKBn SOBn 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 SIBn 1 1 0 0 1 1 0 0 1 0 0 1 0 1 1 0 INTCBnT INTCBnR CBnTSF CBnSCE CCH Shift register 96H 00H SO latch CBnRX CCH 96H 00H (5) (1) (2) (3) (4) (6) (7) (7) (8) (1) Clear the CBnCTL0.CBnPWR bit to 0. (2) Set the CBnCTL1 and CBnCTL2 registers to specify the transfer mode. 442 User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) Chapter 16 (3) Set the CBnTXE, CBnRXE and CBnSCE bits of the CBnCTL0 register to 1 at the same time as specifying the transfer mode using the CBnDIR bit, to set the transmission/reception enabled status. (4) Set the CBnPWR bit to 1 to enable supply of the CSIBn operation. (5) Write the transfer data to the CBnTX register. (6) The transmission enable interrupt request signal (INTCBnT) is received and the transfer data is written to the CBnTX register. (7) The reception complete interrupt request signal (INTCBnR) is output. Read the CBnRX register. (8) Check that the CBnSTR.CBnTSF bit = 0 and set the CBnPWR bit to 0 to stop the operation of CSIBn (end of transmission/reception). To continue transfer, repeat steps (5) to (7) before (8). Note In order to start the entire data transfer the CBnTX register has to be written initially, as done in step (5) above. If this step is omitted also no data will be received. User's Manual U18743EE1V2UM00 443 Chapter 16 Clocked Serial Interface (CSIB) Discontinued transmission In case the CSIB is operating in continuous slave transmission mode (CBnCTL0.CBnTMS = 1, CBnCTL1.CBnCKS[2:0] = 111B) and new data is not written to the CBnTX register the SOBn pin outputs the level of the last bit. Figure 16-4 outlines this behaviour. CBnTX 55H AAH 96H SCKBn SOBn 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 1 1 0 INTCBnT CBnTSF (1) Figure 16-4 (2) (3) (4) (5) (6) (7) Discontinued slave transmission The example shows the situation that two data bytes (55H, AAH) are transmitted correctly, but the third (96H) fails. (1) Data 55H is written (by the CPU) to CBnTX. (2) The master issues the clock SCKBn and transmission of 55H starts. (3) INTCBnT is generated and the next data AAH is written to CBnTX promptly, i.e. before the first data has been transmitted completely. (4) Transmission of the second data AAH continues correctly and INTCBnT is generated. But this time the next data is not written to CBnTX in time. (5) Since there is no new data available in CBnTX, but the master continuous to apply SCKBn clocks, SOBn remains at the level of the transmitted last bit. (6) New data (96H) is written to CBnTX. (7) With the next SCKBn cycle transmission of the new data (96H) starts. As a consequence the master receives a corrupted data byte from (5) onwards, which is made up of a random number of the repeated last bit of the former data and some first bits of the new data. 444 User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) Chapter 16 16.4.7 Continuous mode (slave mode, reception mode) MSB first (CBnCTL0.CBnDIR bit = 0), communication type 1 (see 16.3 (2) CBnCTL1 - CSIBn control register 1), transfer data length = 8 bits (CBnCTL2.CBnCL3 to CBnCTL2.CBnCL0 bits = 0, 0, 0, 0) SCKBn 0 SIBn 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 INTCBnR CBnTSF CBnSCE 55H Shift register AAH 00H AAH 00H 55H CBnRX (1) (2) (3) (4) (5) (6) (6) (7) (1) Clear the CBnCTL0.CBnPWR bit to 0. (2) Set the CBnCTL1 and CBnCTL2 registers to specify the transfer mode. (3) Set the CBnCTL0.CBnRXE and CBnCTL0.CBnSCE bits to 1 at the same time as specifying the transfer mode using the CBnDIR bit, to set the reception enabled status. (4) Set the CBnPWR bit = 1 to enable CSIBn operation. (5) Perform a dummy read of the CBnRX register (reception start trigger). (6) The reception complete interrupt request signal (INTCBnR) is output. Read the CBnRX register. (7) Check that the CBnSTR.CBnTSF bit = 0 and set the CBnPWR bit to 0 to stop the operation of CSIBn (end of reception). To continue transfer, repeat steps (5) and (6) before (7). User's Manual U18743EE1V2UM00 445 Chapter 16 Clocked Serial Interface (CSIB) 16.4.8 Clock timing SCKBn SIBn capture SOBn D7 D6 D5 D4 D3 D2 D1 D0 Reg-R/W INTCBnT interrupt Note INTCBnR interrupt Note CBnTSF Figure 16-5 (i) Communication type 1 (CBnCKP = 0, CBnDAP = 0) SCKBn SIBn capture SOBn D7 D6 D5 D4 D3 D2 D1 Reg-R/W INTCBnT interruptNote 1 INTCBnR interruptNote 2 CBnTSF Figure 16-6 446 (ii) Communication type 3 (CBnCKP = 1, CBnDAP = 0) User's Manual U18743EE1V2UM00 D0 Clocked Serial Interface (CSIB) Chapter 16 SCKBn SIBn capture D7 SOBn D6 D5 D4 D3 D2 D1 D0 Reg-R/W INTCBnT interruptNote 1 INTCBnR interruptNote 2 CBnTSF Figure 16-7 (iii) Communication type 2 (CBnCKP = 0, CBnDAP = 1) SCKBn SIBn capture D7 SOBn D6 D5 D4 D3 D2 D1 D0 Reg-R/W INTCBnT interruptNote 1 INTCBnR interruptNote 2 CBnTSF Figure 16-8 Note (iv) Communication type 4 (CBnCKP = 1, CBnDAP = 1) 1. The INTCBnT interrupt is set when the data written to the transmit buffer is transferred to the data shift register in the continuous transmission or continuous transmission/reception modes. In the single transmission or single transmission/reception modes, the INTCBnT interrupt request signal is not generated, but the INTCBnR interrupt request signal is generated upon completion of communication. 2. The INTCBnR interrupt occurs if reception is correctly completed and receive data is ready in the CBnRX register while reception is enabled, and if an overrun error occurs. In the single mode, the INTCBnR interrupt request signal is generated even in the transmission mode, upon completion of communication. User's Manual U18743EE1V2UM00 447 Chapter 16 Clocked Serial Interface (CSIB) 16.5 Output Pins (1) SCKBn pin When CSIBn operation is disabled (CBnCTL0.CBnPWR bit = 0), the SCKBn pin output status is as follows. CBnCKP CBnCKS2 CBnCKS1 CBnCKS0 0 Don't care Don't care Don't care 1 1 1 1 Note (2) Other than above SCKBn pin output Fixed to high level High impedance Fixed to low level The output level of the SCKBn pin changes if any of the CBnCTL1.CBnCKP and CBnCKS2 to CBnCKS0 bits is rewritten. SOBn pin When CSIBn operation is disabled (CBnPWR bit = 0), the SOBn pin output status is as follows. CBnTXE CBnDAP CBnDIR SOBn pin output 0 x x Fixed to low level 0 x SOBn latch value (low level) 0 CBnTXn value (MSB) 1 CBnTXn value (LSB) 1 Note 1 1. The SOBn pin output changes when any one of the CBnCTL0.CBnTXE, CBnCTL0.CBnDIR bits, and CBnCTL1.CBnDAP bit is rewritten. 2. x: don't care 448 User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) Chapter 16 16.6 Operation Flow (1) Single transmission START Initial setting (CBnCTL0Note, CBnCTL1 registers, etc.) Write CBnTX register (start transfer). INTCBnT interrupt signal? No Yes Data to be transferred next exists? Yes Yes CBnTSF bit = 1? (CBnSTR) Yes No CBnPWR bit = 0 (CBnCTL0) END Note Caution Set the CBnSCE bit to 1 in the initial setting. In the slave mode, data cannot be correctly transmitted if the next transfer clock is input earlier than the CBnTX register is written. User's Manual U18743EE1V2UM00 449 Chapter 16 Clocked Serial Interface (CSIB) (2) Single reception START Initial setting (CBnCTL0Note, CBnCTL1 registers, etc.) CBnRX register dummy read (start reception) INTCBnR interrupt signal? No Yes Last data? Yes No CBnRX register read CBnSCE bit = 0 (CBnCTL0) CBnRX register read CBnPWR bit = 0 (CBnCTL0) END Note Caution 450 Set the CBnSCE bit to 1 in the initial setting. In the single mode, data cannot be correctly received if the next transfer clock is input earlier than the CBnRX register is read. User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) (3) Chapter 16 Single transmission/reception START Initial setting (CBnCTL0Note 1, CBnCTL1 registers, etc.) Write CBnTX register (start transfer). No INTCBnR interrupt signal? Yes Transmission/reception Reception Transmission Read CBnRX register. No Transfer end? Yes Read CBnRX register. No Transfer end? Yes Write CBnTX registerNote 2. No Transfer end? Write CBnTX registerNote 2. B Yes Write CBnTX registerNote 2. A B A CBnPWR bit = 0, CBnTXE bit = CBnRXE bit = 0 (CBnCTL0) END Note 1. Set the CBnSCE bit to 1 in the initial setting. 2. If the next transfer is reception only, dummy data is written to the CBnTX register. Caution Even in the single mode, the CBnSTR.CBnOVE flag is set to 1. If only transmission is used in the transmission/reception mode, therefore, programming without checking the CBnOVE flag is recommended. User's Manual U18743EE1V2UM00 451 Chapter 16 Clocked Serial Interface (CSIB) (4) Continuous transmission START Initial setting (CBnCTL0Note, CBnCTL1 registers, etc.) Write CBnTX register (start transfer). INTCBnT interrupt signal? No Yes Data to be transferred next exists? Yes Yes CBnTSF bit = 1? (CBnSTR) No CBnPWR bit = 0 (CBnCTL0) END Note 452 Set the CBnSCE bit to 1 in the initial setting. User's Manual U18743EE1V2UM00 Yes Clocked Serial Interface (CSIB) (5) Chapter 16 Continuous reception START Initial setting (CBnCTL0Note, CBnCTL1 registers, etc.) CBnRX register dummy read (start reception) INTCBnR bit = 1? No Yes CBnRX register read Yes CBnOVE bit = 1? (CBnSTR) No CBnRX register read Is data being received last data? CBnOVE bit clear (CBnSTR) No Yes CBnSCE bit = 0 (CBnCTL0) CBnRX register read No INTCBnR interrupt signal? Yes CBnRX register read CBnSCE bit = 1 (CBnCTL0) END Note Caution Set the CBnSCE bit to 1 in the initial setting. In the master mode, the clock is output without limit when dummy data is read from the CBnRX register. To stop the clock, execute the flow marked in the above flowchart. In the slave mode, malfunction due to noise during communication can be prevented by executing the flow marked in the above flowchart. Before resuming communication, set the CBnCTL0.CBnSCE bit to 1, and read dummy data from the CBnRX register. User's Manual U18743EE1V2UM00 453 Chapter 16 Clocked Serial Interface (CSIB) (6) Continuous transmission/reception START Initial setting (CBnCTL0Note, CBnCTL1 registers, etc.) Write CBnTX register. INTCBnT interrupt signal? No Yes Is data being transferred last data? Yes INTCBnR interrupt signal? No Write CBnTX register. No Yes CBnRX register read No CBnOVE bit clear (CBnSTR) CBnOVE bit = 0? (CBnSTR) Yes Is data completely received last data? No Yes CBnPWR bit = 0 (CBnCTL0) END Note 454 Set the CBnSCE bit to 1 in the initial setting. User's Manual U18743EE1V2UM00 Clocked Serial Interface (CSIB) Caution Chapter 16 1. When transferring transmit data and receive data using DMA transfer, error processing cannot be performed even if an overrun error occurs during serial transfer. Check that the no overrun error has occurred by reading the CBnSTR.CBnOVE bit after DMA transfer has been completed. 2. In regards to registers that are forbidden from being rewritten during operations (CBnCTL0.CBnPWR bit is 1), if rewriting has been carried out by mistake during operations, set the CBnCTL0.CBnPWR bit to 0 once, then initialize CSIBn. Registers to which rewriting during operation are prohibited are shown below. * CBnCTL0 register: CBnTXE, CBnRXE, CBnDIR, CBnTMS bit * CBnCTL1 register: CBnCKP, CBnDAP, CBnCKS2-CBnCKS0 bit * CBnCTL2 register: CBnCL3-CBnCL0 bit 3. In the single transfer mode (CBnCTL0.CBnTMS bit = 0), when the CBnCTL1.CBnDAP bit is set to 1 and the next reception/transmission are started by using the receive completion interrupt INTCBnR, the reception/ transmission operations from the second time are not performed for 0.5 clocks of the SCKBn after the receive completion interrupt INTCBnR is generated. To perform the continuous transfer, use the continuous transfer mode. 4. When CSIBn is operated in slave mode input an external clock via SCKBn pin only after the transmission -/and/or reception process is started. User's Manual U18743EE1V2UM00 455 Chapter 16 456 Clocked Serial Interface (CSIB) User's Manual U18743EE1V2UM00 Chapter 17 I2C Bus (IIC) This microcontroller has one instance of this I2C Bus interface. Note Throughout this chapter, the individual instances of this I2C Bus interface identified by "n" (n = 0). 17.1 Features The IC provides a synchronous serial interface with the following features: * Supports Master and Slave mode * 8-bit data transfer * Transfer speed - up to 100 kbit/s (Standard Mode) - up to 400 kbit/s (Fast Mode) * Two wire interface - SCLn: serial clock - SDAn: serial data * Noise filter on SCLn and SDAn input 17.2 I2C Pin Configuration The I2C function requires to define the pins SCL0n and SDA0n as input and open drain output pins simultaneously. In the following, the pin configuration registers are listed to be set up properly for I2C: * PMC9.PMC914, PMC9.PMC915 = 1: alternative mode * PFCE9.PFCE914 = PFCE9.PFCE915 = 1, together with PFC9.PFC914 = PFC9.PFC915 = 0: select alternative function 3 * PF9.PFC914 = PF9.PFC915 = 1: open drain output User's Manual U18743EE1V2UM00 457 I2C Bus (IIC) Chapter 17 17.3 Configuration The block diagram of the I2Cn is shown below. Block diagram of I2Cn Figure 17-1 Internal bus IIC status register n (IICSn) MSTSn ALDn EXCn COIn TRCn ACKDn STDn SPDn IIC control register n (IICCn) IICEn LRELn WRELnSPIEn WTIMn ACKEn STTn SPTn Set Slave address register n (SVAn) SDAn Start condition generator Clear Match signal Noise eliminator SO latch IIC shift register n (IICn) DQ CLn1, CLn0 Data hold time correction circuit N-ch open-drain output Acknowledge output circuit Wake-up controller Acknowledge detector Star t condition detector Stop condition detector SCLn Noise eliminator Serial clock controller N-ch open-drain output fXP1 Interrupt request signal generator Serial clock counter Serial clock wait controller Bus status detector IICLKTC Prescaler INTIICn Prescaler IICLKPS = fXP1 to fXP1/5 OCKSENn OCKSTHn OCKSn1 OCKSn0 IIC division clock select register m (OCKSn) CLDn DADn SMCn DFCn CLn1 CLn0 IIC clock select register n (IICCLn) Internal bus 458 User's Manual U18743EE1V2UM00 CLXn STCFn IICBSYn STCENn IICRSVn IIC function expansion register n (IICXn) IIC flag register n (IICFn) I2C Bus (IIC) Chapter 17 A serial bus configuration example is shown below. +VDD +VDD Master CPU1 SDA Slave CPU1 Address 1 Figure 17-2 SCL Serial data bus SDA Master CPU2 Slave CPU2 Serial clock SCL Address 2 SDA Slave CPU3 SCL Address 3 SDA Slave IC SCL Address 4 SDA Slave IC SCL Address N Serial bus configuration example using I2C bus I2Cn includes the following hardware. Table 17-1 Configuration of I2Cn Item Configuration Registers IIC shift register n (IICn) Slave address register n (SVAn) Control registers IIC control register n (IICCn) IIC status register n (IICSn) IIC flag register n (IICF0n) IIC clock select register n (IICCLn) IIC function expansion register n (IICXn) IIC division clock select registers (OCKSn) User's Manual U18743EE1V2UM00 459 I2C Bus (IIC) Chapter 17 (1) IIC shift register n (IICn) The IICn register converts 8-bit serial data into 8-bit parallel data and vice versa, and can be used for both transmission and reception. Write and read operations to the IICn register are used to control the actual transmit and receive operations. (2) Slave address register n (SVAn) The SVAn register sets local addresses when in slave mode. (3) SO latch The SO latch is used to retain the output level of the SDA0n pin. (4) Wakeup controller This circuit generates an interrupt request when the address received by this register matches the address value set to the SVAn register or when an extension code is received. (5) Prescaler This selects the sampling clock to be used. (6) Serial clock counter This counter counts the serial clocks that are output and the serial clocks that are input during transmit/receive operations and is used to verify that 8-bit data was transmitted or received. (7) Interrupt request signal generator This circuit controls the generation of interrupt request signals (INTIICn). An I2C interrupt is generated following either of two triggers: * Falling edge of eighth or ninth clock of the serial clock (set by IICCn.WTIMn bit) * Interrupt occurrence due to stop condition detection (set by IICCn.SPIEn bit) (8) Serial clock controller In master mode, this circuit generates the clock output via the SCL0n pin from the sampling clock. (9) Serial clock wait controller This circuit controls the wait timing. (10) ACK output circuit, stop condition detector, start condition detector, and ACK detector These circuits are used to output and detect various control signals. 460 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 (11) Data hold time correction circuit This circuit generates the hold time for data corresponding to the falling edge of the SCL0n pin. (12) Start condition generator A start condition is issued when the IICCn.STTn bit is set. However, in the communication reservation disabled status (IICFn.IICRSVn = 1), this request is ignored and the IICFn.STCFn bit is set if the bus is not released (IICFn.IICBSYn = 1). (13) Bus status detector Whether the bus is released or not is ascertained by detecting a start condition and stop condition. However, the bus status cannot be detected immediately after operation, so set the bus status detector to the initial status by using the IICFn.STCENn bit. (14) Stop condition generator A stop condition is generated when the IICC0.SPT0 bit is set. User's Manual U18743EE1V2UM00 461 I2C Bus (IIC) Chapter 17 17.4 IIC Registers The I2C interfaces are controlled by the following registers. * IIC control registers IICCn * IIC status registers IICSn * IIC flag registers IICFn * IIC clock select registers IICCLn * IIC function expansion registers IICXn * IIC division clock select registers OCKSn The following registers are also used. * IIC shift registers IICn * Slave address registers SVAn 462 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 (1) IICCn - IICn control registers The IICCn registers enable/stop I2Cn operations, set the wait timing, and set other I2C operations. These registers can be read or written in 8-bit or 1-bit units. Set the SPIE0, WTIM0, and ACKE0 bits when the IICE bit is 0 or during the wait period. When setting the IICE0 bit from "0" to "1", these bits can also be set at the same time. RESET input sets this register to 00H. After reset: 00H IICCn R/W Address: IICC0 FFFFFD82H <7> <6> <5> <4> <3> <2> <1> <0> IICEn LRELn WRELn SPIEn WTIMn ACKEn STTn SPTn Specification of I2Cn operation enable/disable IICEn 0 Operation stopped. IICSn register resetNote 1. Internal operation stopped. 1 Operation enabled. Condition for clearing (IICEn = 0) Condition for setting (IICEn = 1) * Cleared by instruction * After reset * Set by instruction LRELn Exit from communications 0 Normal operation 1 This exits from the current communication operation and sets stand-by mode. This setting is automatically cleared after being executed. Its uses include cases in which a locally irrelevant extension code has been received. The SCL0n and SDA0n lines are set to high impedance. The STTn and SPTn bits and the MSTSn, EXCn, COIn, TRCn, ACKDn, and STDn bits of the IICSn register are cleared. The stand-by mode following exit from communications remains in effect until the following communication entry conditions are met. * After a stop condition is detected, restart is in master mode. * An address match occurs or an extension code is received after the start condition. Condition for clearing (LRELn = 0)Note 2 Condition for setting (LRELn = 1) * Automatically cleared after execution * After reset * Set by instruction WRELn Wait cancellation control 0 Wait not cancelled 1 Wait cancelled. This setting is automatically cleared after wait is cancelled. Condition for clearing (WRELn = 0)Note 2 Condition for setting (WRELn = 1) * Automatically cleared after execution * After reset * Set by instruction User's Manual U18743EE1V2UM00 463 I2C Bus (IIC) Chapter 17 SPIEn Enable/disable generation of interrupt request when stop condition is detected 0 Disabled 1 Enabled Condition for clearing (SPIEn = 0)Note 2 Condition for setting (SPIEn = 1) * Cleared by instruction * After reset * Set by instruction Note 1. The IICS register, IICFn.STCFn and IICFn.IICBSYn bits, and IICCLn.CLDn and IICCLn.DADn bits are reset. 2. This flag's signal is invalid when the IICEn = 0. WTIMn Control of wait and interrupt request generation 0 Interrupt request is generated at the eighth clock's falling edge. Master mode: After output of eight clocks, clock output is set to low level and wait is set. Slave mode: After input of eight clocks, the clock is set to low level and wait is set for the master device. 1 Interrupt request is generated at the ninth clock's falling edge. Master mode: After output of nine clocks, clock output is set to low level and wait is set. Slave mode: After input of nine clocks, the clock is set to low level and wait is set for the master device. In order to generate the ninth clock on SCLn, the wait status must be cancelled by writing to IICn or setting IICCn.WRELn = 1. Consequently the ninth clock will be delayed until the wait status is cancelled. During address transfer, an interrupt occurs at the falling edge of the ninth clock regardless of this bit setting. This bit setting becomes valid when the address transfer is completed. In master mode, a wait is inserted at the falling edge of the ninth clock during address transfer. For a slave device that has received a local address, a wait is inserted at the falling edge of the ninth clock after an ACK signal is issued. When the slave device has received an extension code, however, a wait is inserted at the falling edge of the eighth clock. Condition for clearing (WTIMn = 0)Note Condition for setting (WTIMn = 1) * Cleared by instruction * After reset * Set by instruction ACKEn Acknowledgement control 0 Acknowledgment disabled. 1 Acknowledgment enabled. During the ninth clock period, the SDA0n line is set to low level. The ACKE0 bit setting is invalid for address reception. In this case, ACK is generated when the addresses match. However, the ACKE0 bit setting is valid for reception of the extension code. Condition for clearing (ACKEn = 0)Note Condition for setting (ACKEn = 1)Note * Cleared by instruction * After reset * Set by instruction Note 464 This flag's signal is invalid when the IICEn = 0. User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 STTn Start condition trigger 0 Start condition is not generated. 1 When bus is released (in STOP mode): A start condition is generated (for starting as master). The SDA0n line is changed from high level to low level and then the start condition is generated. Next, after the rated amount of time has elapsed, the SCL0n line is changed to low level. During communication with a third party: If the communication reservation function is enabled (IICFn.IICRSVn = 0) * This trigger functions as a start condition reserve flag. When set, it releases the bus and then automatically generates a start condition. If the communication reservation function is disabled (IICRSVn = 1) * The IICFn.STCFn bit is set. This trigger does not generate a start condition. In the wait state (when master device): A restart condition is generated after the wait is released. Cautions concerning set timing For master reception: Cannot be set during transfer. Can be set only when the ACKEn bit has been set to 0 and the slave has been notified of final reception. For master transmission: A start condition cannot be generated normally during the ACK period. Set during the wait periodafter the ninth clock output. For slave: Even when the communication reservation function is disabled (IICRSVn bit = 1), the communication reservation status is entered. Setting to 1 at the same time as the SPT0 bit is prohibited. When the STT0 bit is set to 1, setting the STT0 bit to 1 again is disabled until the bit is cleared to 0. Condition for clearing (STTn = 0)Note Condition for setting (STTn = 1) * Cleared by loss in arbitration * Cleared after start condition is generated by master device * When the LRELn = 1 (communication save) * When the IICEn= 0 (operation stop) * After reset * Set by instruction Note 1. Clearing the IICEn bit to 0 invalidates the signals of this flag. 2. The STTn bit is 0 if it is read immediately after data setting. Caution If the I2C0 operation is enabled (IICE0 bit = 1) when the SCL00 line is high level and the SDA00 line is low level, the start condition is detected immediately. To avoid this, after enabling the I2C0 operation, immediately set the LREL0 bit to 1 with a bit manipulation instruction. Remark The LREL0 and WREL0 bits are 0 when read after the data has been set. User's Manual U18743EE1V2UM00 465 I2C Bus (IIC) Chapter 17 SPTn Stop condition trigger 0 Stop condition is not generated. 1 Stop condition is generated (termination of master device's transfer). After the SDA0n line goes to low level, either set the SCL0n line to high level or wait until it goes to high level. Next, after the rated amount of time has elapsed, the SDA0n line is changed from low level to high level and a stop condition is generated. Cautions concerning set timing For master reception: Cannot be set during transfer. Can be set only when the ACKEn bit has been set to 0 and during the wait period after the slave has been notified of final reception. For master transmission: A stop condition cannot be generated normally during the ACK period. Set (1) during the wait period. * SPTn cannot be set at the same time as the STTn bit. * The SPTn bit can be set only when in master modeNote 1. * When the WTIMn bit has been set to 0 and the SPTn bit is set during the wait period that follows output of eight clocks, note that a stop condition will be generated during the high-level period of the ninth clock. When the ninth clock must be output to apply the ACK on the bus by the receiving device, proceed as follows: - Change IICCn.WTIMn from 0 to 1 in order to receive an additional interrupt after the ninth clock. - Cancel the wait state by IICCn.WRELn = 1 or by writing to the IICn register. - Upon the interrupt after the ninth clock require to set the stop condition by IICCn.STPn = 1. By this the wait status will be cancelled and the stop condition will be generated on the bus. * When the SPT0 bit is set to 1, setting the SPT0 bit to 1 again is disabled until the bit is cleared to 0. Condition for clearing (SPTn = 0)Note 2 Condition for setting (SPTn = 1) * * * * * * Set by instruction Cleared by loss in arbitration Automatically cleared after stop condition is detected When the LRELn = 1 (communication save) When the IICEn = 0 (operation stop) After reset Note 1. Set the SPTn bit only in master mode. However, when the IICRSVn bit is 0, the SPTn bit must be set and a stop condition generated before the first stop condition is detected following the switch to the operation enabled status. For details, see "Cautions" on page 511. 2. Clearing the IICEn bit to 0 invalidates the signals of this flag. 3. The SPTn bit is 0 if it is read immediately after data setting. Caution 466 When the TRCn = 1, the WRELn bit is set during the ninth clock and wait is cancelled, after which the TRCn bit is cleared and the SDA0n line is set to high impedance. User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 (2) IICSn - IICn status registers The IICSn registers indicate the status of the I2Cn bus. These registers are read-only, in 8-bit or 1-bit units. The IICS0 register can only be read when the IICC0.STT0 bit is 1 or during the wait period. * When the CPU operates with the subclock and the main clock oscillation is stopped * When the CPU operates with the low speed internal oscillation clock RESET input sets this register to 00H. After reset: 00H IICSn R Address: IICS0 FFFFFD86H <7> <6> <5> <4> <3> <2> <1> <0> MSTSn ALDn EXCn COIn TRCn ACKDn STDn SPDn MSTSn Master device status 0 Slave device status or communication stand-by status 1 Master device communication status Condition for clearing (MSTSn = 0) Condition for setting (MSTSn = 1) * * * * * When a start condition is generated When a stop condition is detected When the ALDn = 1 (arbitration loss) Cleared by LRELn = 1 (communication save) When the IICEn bit changes from 1 to 0 (operation stop) * After reset ALDn Arbitration loss detection 0 This status means either that there was no arbitration or that the arbitration result was a "win". 1 This status indicates the arbitration result was a "loss". The MSTSn bit is cleared. Condition for clearing (ALDn = 0) Condition for setting (ALDn = 1) * Automatically cleared after the IICSn register is readNote * When the IICEn bit changes from 1 to 0 (operation stop) * After reset * When the arbitration result is a "loss". Note Any bit manipulation instruction targeting this register also clears this bit. User's Manual U18743EE1V2UM00 467 I2C Bus (IIC) Chapter 17 EXCn Detection of extension code reception 0 Extension code was not received. 1 Extension code was received. Condition for clearing (EXCn = 0) Condition for setting (EXCn = 1) * * * * * When a start condition is detected When a stop condition is detected Cleared by LRELn = 1 (communication save) When the IICEn bit changes from 1 to 0 (operation stop) * After reset COIn When the higher four bits of the received address data are either "0000" or "1111" (set at the rising edge of the eighth clock). Matching address detection 0 Addresses do not match. 1 Addresses match. Condition for clearing (COIn = 0) Condition for setting (COIn = 1) * * * * * When a start condition is detected When a stop condition is detected Cleared by LRELn bit = 1 (communication save) When the IICEn bit changes from 1 to 0 (operation stop) * After reset TRCn When the received address matches the local address (SVAn register) (set at the rising edge of the eighth clock). Transmit/receive status detection 0 Receive status (other than transmit status). The SDA0n line is set to high impedance. 1 Transmit status. The value in the SO latch is enabled for output to the SDA0n line (valid starting at the falling edge of the first byte's ninth clock). Condition for clearing (TRCn = 0) Condition for setting (TRCn = 1) * When a stop condition is detected * Cleared by LRELn = 1 (communication save) * When the IICEn bit changes from 1 to 0 (operation stop) * Cleared by WRELn = 1Note * When the ALDn bit changes from 0 to 1 (arbitration loss) * After reset Master * When a start condition is generated Slave * When "1" is input by the first byte's LSB (transfer direction specification bit) Master * When "1" is output to the first byte's LSB (transfer direction specification bit) Slave * When a start condition is detected When not used for communication ACKDn 0 468 ACK detection ACK was not detected. User's Manual U18743EE1V2UM00 I2C Bus (IIC) 1 Chapter 17 ACK was detected. Condition for clearing (ACKDn = 0) Condition for setting (ACKD = 1) * * * * * After the SDA0n bit is set to low level at the rising edge of the SCL0n pin's ninth clock When a stop condition is detected At the rising edge of the next byte's first clock Cleared by LRELn = 1 (communication save) When the IICEn bit changes from 1 to 0 (operation stop) * After reset Note The TRCn bit is cleared and SDA0n line becomes high impedance when the WRELn bit is set and the wait state is canceled at the ninth clock by TRCn = 1. STDn Start condition detection 0 Start condition was not detected. 1 Start condition was detected. This indicates that the address transfer period is in effect Condition for clearing (STDn = 0) Condition for setting (STDn = 1) * When a stop condition is detected * At the rising edge of the next byte's first clock following address transfer * Cleared by LRELn = 1 (communication save) * When the IICEn bit changes from 1 to 0 (operation stop) * After reset * When a start condition is detected SPDn Stop condition detection 0 Stop condition was not detected. 1 Stop condition was detected. The master device's communication is terminated and the bus is released. Condition for clearing (SPDn = 0) Condition for setting (SPDn = 1) * At the rising edge of the address transfer byte's first clock following setting of this bit and detection of a start condition * When the IICEn bit changes from 1 to 0 (operation stop) * After reset * When a stop condition is detected User's Manual U18743EE1V2UM00 469 I2C Bus (IIC) Chapter 17 (3) IICFn - IICn flag registers The registers set the I2Cn operation mode and indicate the I2C bus status. These registers can be read or written in 8-bit or 1-bit units. However, the STCFn and IICBSYn bits are read-only. IICRSVn enables/disables the communication reservation function. The initial value of the IICBSYn bit is set by using the STCENn bit (see "Cautions" on page 511). The IICRSVn and STCENn bits can be written only when operation of I2Cn is disabled (IICCn.IICEn = 0). After operation is enabled, IICFn can be read. RESET input sets this register to 00H. After reset: 00H IICFn R/WNote Address: IICF0 FFFFFD8AH <7> <6> 5 4 3 2 <1> <0> STCFn IICBSYn 0 0 0 0 STCENn IICRSVn STCFn STTn clear 0 Start condition issued 1 Start condition cannot be issued, STTn bit cleared Condition for clearing (STCFn = 0) Condition for setting (STCFn = 1) * Cleared by IICCn.STTn = 1 * When IICC0.IICE0 bit = 0 * After reset * When start condition is not issued and STTn flag is cleared during communication reservation is disabled (IICRSVn = 1). I2Cn bus status IICBSYn 0 Bus released status 1 Bus communication status Condition for clearing (IICBSYn = 0) Condition for setting (IICBSYn = 1) * When stop condition is detected * When IICC0.IICE0 bit = 0 * After reset * When start condition is detected * By setting the IICCn.IICEn bit when the STCENn = 0 STCENn Initial start enable trigger 0 Start conditions cannot be generated until a stop condition is detected following operation enable (IICEn bit = 1). 1 Start conditions can be generated even if a stop condition is not detected following operation enable (IICEn = 1). Condition for clearing (STCENn = 0) Condition for setting (STCENn = 1) * When start condition is detected * After reset * Setting by instruction 470 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 IICRSVn Communication reservation function disable bit 0 Communication reservation enabled 1 Communication reservation disabled Condition for clearing (IICRSVn = 0) Condition for setting (IICRSVn = 1) * Clearing by instruction * After reset * Setting by instruction Note Caution Bits 6 and 7 are read-only bits. 1. Write the STCENn bit only when operation is stopped (IICEn = 0). 2. When the STCENn = 1, the bus released status (IICBSYn = 0) is recognized regardless of the actual bus status immediately after the I2Cn bus operation is enabled. Therefore, to issue the first start condition (STTn = 1), it is necessary to confirm that the bus has been released, so as to not disturb other communications. 3. Write the IICRSVn bit only when operation is stopped (IICEn = 0). User's Manual U18743EE1V2UM00 471 I2C Bus (IIC) Chapter 17 (4) IICCLn - IICn clock select registers The IICCLn registers set the transfer clock for the I2Cn bus. These registers can be read or written in 8-bit or 1-bit units. However, the CLDn and DADn bits are read-only. The SMCn, CLn1, and CLn0 bits are set by the combination of the IICXn.CLXn bit and the OCKSTHn, OCKSn[1:0] bits of the OCKSn register (see "Transfer rate setting" on page 475). Reset input clears these registers to 00H. After reset: 00H IICCLn Note R/WNote Address: IICCL0 FFFFFD84H 7 6 <5> <4> 3 2 1 0 0 0 CLDn DADn SMCn DFCn CLn1 CLn0 Bits 4 to 7 of IICCLn are read-only bits. CLDn Detection of SCL0n pin level (valid only when IICCn.IICEn = 1) 0 The SCL0n pin was detected at low level. 1 The SCL0n pin was detected at high level. Condition for clearing (CLDn = 0) Condition for setting (CLDn = 1) * When the SCL0n pin is at low level * When the IICEn = 0 (operation stop) * After reset * When the SCL0n pin is at high level DADn Detection of SDA0n pin level (valid only when IICEn = 1) 0 The SDA0n pin was detected at low level. 1 The SDA0n pin was detected at high level. Condition for clearing (DADn = 0) Condition for setting (DAD0n = 1) * When the SDA0n pin is at low level * When the IICEn = 0 (operation stop) * After reset * When the SDA0n pin is at high level SMCn Operation mode switching 0 Operation in standard mode. 1 Operation in fast-speed mode. DFCn Digital filter operation control 0 Digital filter off. 1 Digital filter on. The digital filter can be used only in fast-speed mode. In fast-speed mode, the transfer clock does not vary regardless of the DFCn bit setting (on/off). The digital filter is used to eliminate noise in fast-speed mode. 472 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 (5) IICXn - IICn function expansion registers The IICXn registers provide additional transfer data rate configuration in fastspeed mode. Setting of the IICXn.CLXn is performed in combination with the IICCLn.SMCn, IICCLn.CLn[1:0], OCKSn.OCKSTHn and OCKSn.OCKSn[1:0] (refer to "Transfer rate setting" on page 475) Reset input clears these registers to 00H. After reset: 00H IICXn R/W Address: IICX0 FFFFFD85H 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 CLXn User's Manual U18743EE1V2UM00 473 I2C Bus (IIC) Chapter 17 (6) OCKSn - IICn division clock select registers The OCKSn registers control the I2Cn division clock. These registers can be read or written in 8-bit units. RESET input sets this register to 00H. After reset: 00H R/W OCKSn Address: OCKS0 FFFFF340H 7 6 5 4 3 2 1 0 0 0 0 OCKSENn OCKSTHn 0 OCKSn1 OCKSn0 Operation setting of I2C division clock OCKSENn 0 Disable I2C division clock operation. 1 Enable I2C division clock operation. Selection of I2C division clock IICLKPS OCKSTHn OCKSn1 OCKSn0 0 0 0 fxx/2 fxx/4 0 0 1 fxx/3 fxx/6 0 1 0 fxx/4 fxx/8 0 1 1 fxx/5 fxx/10 1 X X fxx fxx/2 Note PRSI = 0 PRSI can be set by the option bytes: Refer to "Flash Memory" on page 259 for details. 474 User's Manual U18743EE1V2UM00 PRSI = 1 I2C Bus (IIC) Chapter 17 (7) Transfer rate setting The nominal transfer rate of the I2C interface is determined by the root clock source fXP1. The frequency of fXP1 can be set to fXP1or fXP1/2 by the PRSI bit of the option byte (007BH). * The fXP1 can be divided by 1 to 5, configured by OCKSn.OCKSTHn and OCKSn.OCKSTn[1:0] (refer to "OCKSn - IICn division clock select registers" on page 474). The output clock of this divider is named IICLKPS. * IICLKPS is passed through another configurable divider that finally outputs the clock for the serial transfer IICLKTC. This divider is configured by IICCLn.CL[1:0] and IICXn.CLX0 according to the following tables: Note The I2C interface input clock IICLKPS must lie in the range of 1 MHz to 10 MHz. The following tables summarize the transfer rate settings: Note PRSI IICCLn.SMCn Mode Table 0 0 standard Table 17-2 on page 475 0 1 fast-speed Table 17-3 on page 476 1 0 standard Table 17-4 on page 476 1 1 fast-speed Table 17-5 on page 477 PRSI can be set by the option bytes: Refer to "Flash Memory" on page 259 for details. Table 17-2 PRSI = 0: Transfer rate settings in standard mode (IICCLn.SMCn = 0) IICXn. IICCLn. IICCLn. CLXn CLn1 CLn0 0 0 0 0 0 0 1 1 0 1 0 1 Other than above Selected Clock OCKSn fxx/2 10H fxx/3 Transfer Clock Possible Main System Clock Range (fxx) (Reference) Transfer speed from to fxx/88 4 MHz 8.38 MHz 45.5KHz ~ 95.2KHz 11H fxx/132 6 MHz 12.57 MHz 45.5KHz ~ 95.2KHz fxx/4 12H fxx/176 8 MHz 16.76 MHz 45.5KHz ~ 95.2KHz fxx/5 13H fxx/220 10 MHz 20.00 MHz 45.5KHz ~ 90.9KHz fxx 18H fxx/44 4 MHz 4.19 MHz 90.9KHz ~ 95.2KHz fxx/2 10H fxx/172 8.38 MHz 16.76 MHz 48.7KHz ~ 97.4KHz fxx/3 11H fxx/258 12.57 MHz 20.00 MHz 48.7KHz ~ 77.5KHz fxx/4 12H fxx/344 16.76 MHz 20 MHz 48.7KHz ~ 58.1KHz fxx 13H fxx/86 4.19 MHz 8.38 MHz 48.7KHz ~ 97.4KHz fxx - fxx/86 4.19 MHz 8.38 MHz 48.7KHz ~ 97.4KHz fxx/2 10H fxx/132 12.80 MHz 97.0KHz fxx/3 11H fxx/198 19.20 MHz 97.0KHz fxx 18H fxx/66 6.40 MHz 97.0KHz Setting Prohibited - User's Manual U18743EE1V2UM00 - - - 475 I2C Bus (IIC) Chapter 17 Table 17-3 PRSI = 0: Transfer rate settings in fast-speed mode (IICCLn.SMCn = 1) IICXn. IICCLn. IICCLn. CLXn CLn1 CLn0 0 0 0 1 1 0 X 1 0 1 0 1 X 1 0 Other than above Table 17-4 0 0 OCKSn fxx/2 10H fxx/3 Transfer Clock fxx/48 8 MHz 16.76 MHz 166.7KHz ~ 349.2KHz 11H fxx/72 12 MHz 20 MHz 166.7KHz ~ 277.8KHz fxx/4 12H fxx/96 16 MHz 20 MHz 166.7KHz ~ 208.3KHz fxx/5 13H fxx/120 fxx 18H fxx/24 fxx/2 10H fxx/36 12.80 MHz 355.6KHz fxx/3 11H fxx/54 19.20 MHz 355.6KHz fxx 18H fxx/18 6.4 MHz 355.6KHz fxx/2 10H fxx/24 8 MHz 8.38 MHz 333.3KHz ~ 349.2KHz fxx/3 11H fxx/36 12 MHz 12.57 MHz 333.3KHz ~ 349.2KHz fxx/4 12H fxx/48 16 MHz 16.67 MHz 333.3KHz ~ 349.2KHz fxx/5 13H fxx/60 fxx 18H fxx/12 4 MHz 4.19 MHz 333.3KHz ~ 349.2KHz fxx - fxx/12 4 MHz 4.19 MHz 333.3KHz ~ 349.2KHz - - - - 20 MHz 4 MHz 166.7KHz 8.38 MHz 20 MHz 166.7KHz ~ 349.2KHz 333.3KHz PRSI = 1: Transfer rate settings in standard mode (IICCLn.SMCn = 0) Selected Clock OCKSn fxx/4 10H fxx/6 Transfer Clock Possible Main System Clock Range (fxx) (Reference) Transfer speed from to fxx/176 8 MHz 16.76 MHz 45.5KHz ~ 95.2KHz 11H fxx/264 12 MHz 20.00 MHz 45.5KHz ~ 95.2KHz fxx/8 12H fxx/352 16 MHz 20.00 MHz 45.5KHz ~ 95.2KHz fxx/10 13H fxx/440 fxx/2 18H fxx/88 4 MHz 8.38 MHz 90.9KHz ~ 95.2KHz fxx/4 10H fxx/344 16.76 MHz 20.00 MHz 48.7KHz ~ 97.4KHz fxx/2 18H fxx/172 8.38 MHz 16.76 MHz 48.7KHz ~ 97.4KHz 8.38 MHz 16.76 MHz 48.7KHz ~ 97.4KHz 0 1 0 1 0 fxx/2 - fxx/172 0 1 1 fxx/2 18H fxx/132 476 (Reference) Transfer speed to 0 Other than above Possible Main System Clock Range (fxx) from Setting Prohibited IICXn. IICCLn. IICCLn. CLXn CLn1 CLn0 0 Selected Clock Setting Prohibited - User's Manual U18743EE1V2UM00 20 MHz 45.5KHz 12.80 MHz - 97.0KHz - - I2C Bus (IIC) Chapter 17 Table 17-5 PRSI = 1: Transfer rate settings in fast-speed mode (IICCLn.SMCn = 1) IICXn. IICCLn. IICCLn. CLXn CLn1 CLn0 Selected Clock OCKSn fxx/4 10H fxx/2 Transfer Clock Possible Main System Clock Range (fxx) (Reference) Transfer speed from to fxx/96 16 MHz 20.00 MHz 166.7KHz ~ 208.3KHz 18H fxx/48 8 MHz 8.38 MHz 166.7KHz ~ 349.2KHz 8 MHz 8.38 MHz 166.7KHz ~ 349.2KHz 0 0 X 0 1 0 fxx/2 - fxx/48 0 1 1 fxx/2 18H fxx/36 1 0 X fxx/4 10H fxx/48 16 MHz 16.76 MHz 333.3KHz ~ 349.2KHz fxx/2 18H fxx/24 8 MHz 8.38 MHz 333.3KHz ~ 349.2KHz 1 1 0 fxx/2 - fxx/24 8 MHz 8.38 MHz 333.3KHz ~ 349.2KHz - - - - Other than above Setting Prohibited User's Manual U18743EE1V2UM00 12.80 MHz 355.6KHz 477 I2C Bus (IIC) Chapter 17 Clock Stretching Heavy capacitive load and the dimension of the external pull-up resistor on the I2C bus pins may yield extended rise times of the rising edge of SCLn and SDAn. Since the controller senses the level of the I2C bus signals it recognizes such situation and takes countermeasures by stretching the clock SCLn in order to ensure proper high level time tSCLH of SCLn. After the microcontroller releases the (open-drain) SCLn pin it waits until the SCLn level exceeds the valid high level threshold VthH. Then it does not pull SCLn to low level before the nominal high level time tSCLH_nom has elapsed. This mechanism is the same used, when a slow I2C slave device is pulling down SCLn to low level to initiate a wait state. Note It is assumed that the rise time fr is much bigger than the fall time ff. Figure 17-3 shows an example. VthH SCL signal effective SCL clock tr tSCLH tSCLL tr TSCL_nom TSCL_eff Figure 17-3 Clock Stretching of SCLn The effective clock frequency appearing at the SCLn pin calculates to fSCL_eff = 1 / (TSCL_nom + tr) With a nominal frequency of fSCL_nom = 355.6 KHz (TSCL_nom = 2.812 s and a rise time of tr = 135 ns the effective frequency is feff = 339.31 KHz. 478 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 (8) IICn - IICn shift registers The IICn registers are used for serial transmission/reception (shift operations) synchronized with the serial clock. These registers can be read or written in 8bit units, but data should not be written to the IICn register during a data transfer. Access (read/write) this register only during the wait period. Accessing this register in communication states other than the wait period is prohibited. However, for the master device, this register can be written once only after the transmission trigger bit (IICC0.STT0 bit) has been set to 1. A wait state is released by writing the IICn register during the wait period, and data transfer is started. Reset input clears these registers to 00H. After reset: 00H R/W 7 Address: 6 IC0 FFFFFD80H 5 4 3 2 1 0 IICn (9) SVAn - IICn slave address registers The SVAn registers hold the I2C bus's slave addresses. These registers can be read or written in 8-bit units, but bit 0 should be fixed to 0. Rewriting these registers is prohibited when the IICS0.STD0 bit = 1 Reset input sets this register to 00H. After reset: 00H R/W 7 Address: 6 SVA0 FFFFFD83H 5 SVAn 4 3 2 1 0 0 User's Manual U18743EE1V2UM00 479 I2C Bus (IIC) Chapter 17 17.5 I2C Bus Mode Functions 17.5.1 Pin functions The serial clock pin (SCL0n) and serial data bus pin (SDA0n) are configured as follows. SCL0n This pin is used for serial clock input and output. This pin is an N-ch open-drain output for both master and slave devices. Input is Schmitt input. SDA0n This pin is used for serial data input and output. This pin is an N-ch open-drain output for both master and slave devices. Input is Schmitt input. Since outputs from the serial clock line and the serial data bus line are N-ch open-drain outputs, an external pull-up resistor is required. VDD Slave device Master device SCL0n SCL0n (Clock output) Clock output VDD Clock input (Clock input) SDA0n Data output Data output Data input Data input Figure 17-4 480 SDA0n Pin configuration diagram User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 17.6 I2C Bus Definitions and Control Methods The following section describes the I2C bus's serial data communication format and the signals used by the I2C bus. The transfer timing for the "start condition", "address", "transfer direction specification", "data" and "stop condition" output via the I2C bus's serial data bus is shown below. 1 to 7 SCL0n 8 9 1 to 7 R/W ACK Data 8 9 1 to 7 ACK Data 8 9 SDA0n Start Address condition Figure 17-5 ACK Stop condition I2C bus serial data transfer timing The master device outputs the start condition, slave address, and stop condition. The acknowledge signal (ACK) can be output by either the master or slave device (normally, it is output by the device that receives 8-bit data). The serial clock (SCL0n) is continuously output by the master device. However, in the slave device, the SCL0n pin's low-level period can be extended and a wait can be inserted. 17.6.1 Start condition A start condition is met when the SCL0n pin is high level and the SDA0n pin changes from high level to low level. The start condition for the SCL0n and SDA0n pins is a signal that the master device outputs to the slave device when starting a serial transfer. The slave device can defect the start condition. H SCL0n SDA0n Figure 17-6 Start condition A start condition is output when the IICCn.STTn bit is set (1) after a stop condition has been detected (IICSn.SPDn bit = 1). When a start condition is detected, the IICSn.STDn bit is set (1). User's Manual U18743EE1V2UM00 481 I2C Bus (IIC) Chapter 17 Caution When the IICC0.IICE0 bit of the microcontroller is set to 1 while communications with other devices are in progress, the start condition may be detected depending on the status of the communication line. Be sure to set the IICC0.IICE0 bit to 1 when the SCL00 and SDA00 lines are high level. 17.6.2 Addresses The 7 bits of data that follow the start condition are defined as an address. An address is a 7-bit data segment that is output in order to select one of the slave devices that are connected to the master device via the bus lines. Therefore, each slave device connected via the bus lines must have a unique address. The slave devices include hardware that detects the start condition and checks whether or not the 7-bit address data matches the data values stored in the SVAn register. If the address data matches the values of the SVAn register, the slave device is selected and communicates with the master device until the master device transmits a start condition or stop condition. SCL0n 1 2 3 4 5 6 7 8 SDA0n AD6 AD5 AD4 AD3 AD2 AD1 AD0 R/W Address 9 Note INTIICn Figure 17-7 Note Address The interrupt request signal (INTIICn) is generated if a local address or extension code is received during slave device operation. The slave address and the eighth bit, which specifies the transfer direction as described in "Transfer direction specification" on page 483, are written together to IIC shift register n (IICn) and then output. Received addresses are written to the IICn register. The slave address is assigned to the higher 7 bits of the IICn register. 482 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 17.6.3 Transfer direction specification In addition to the 7-bit address data, the master device sends 1 bit that specifies the transfer direction. When this transfer direction specification bit has a value of 0, it indicates that the master device is transmitting data to a slave device. When the transfer direction specification bit has a value of 1, it indicates that the master device is receiving data from a slave device. SCL0n 1 2 3 4 5 6 7 8 SDA0n AD6 AD5 AD4 AD3 AD2 AD1 AD0 R/W 9 Transfer direction specification Note INTIICn Figure 17-8 Note Transfer direction specification The INTIICn signal is generated if a local address or extension code is received during slave device operation. 17.6.4 Acknowledge signal (ACK) The acknowledge signal (ACK) is used by the transmitting and receiving devices to confirm serial data reception. The receiving device returns one ACK signal for each 8 bits of data it receives. The transmitting device normally receives an ACK signal after transmitting 8 bits of data. The detection of ACK is confirmed with the IICS0.ACKD0 bit. However, when the master device is the receiving device, it does not output an ACK signal after receiving the final data to be transmitted. The transmitting device detects whether or not an ACK signal is returned after it transmits 8 bits of data. When an ACK signal is returned, the reception is judged as normal and processing continues. If the slave device does not return an ACK signal, the master device outputs either a stop condition or a restart condition and then stops the current transmission. Failure to return an ACK signal may be caused by the following three factors: * Reception was not performed normally. * The final data was received. * The receiving device (slave) does not exist for the specified address. When the receiving device sets the SDA0n line to low level during the ninth clock, the ACK signal becomes active (normal receive response). When the IICCn.ACKEn bit is set to 1, automatic ACK signal generation is enabled. Transmission of the eighth bit following the 7 address data bits causes the IICSn.TRCn bit to be set. When this TRCn bit's value is 0, it indicates receive mode. Therefore, the ACKEn bit should be set to 1. When the slave device is receiving (when TRCn bit = 0), if the slave device does not need to receive any more data after receiving several bytes, clearing User's Manual U18743EE1V2UM00 483 I2C Bus (IIC) Chapter 17 the ACKEn bit to 0 will prevent the master device from starting transmission of the subsequent data. Similarly, when the master device is receiving (when TRCn bit = 0) and the subsequent data is not needed and when either a restart condition or a stop condition should therefore be output, clearing the ACKEn bit to 0 will prevent the ACK signal from being returned. This prevents the MSB from being output via the SDA0n line (i.e., stops transmission) during transmission from the slave device. SCL0n 1 2 3 4 5 6 7 SDA0n AD6 AD5 AD4 AD3 AD2 AD1 AD0 Figure 17-9 8 9 R/W ACK ACK signal When the local address is received, an ACK signal is automatically output in synchronization with the falling edge of the SCL0n pin's eighth clock regardless of the value of the ACKEn bit. No ACK signal is output if the received address is not a local address. The ACK signal output method during data reception is based on the wait timing setting, as described below. When 8-clock wait is selected (IICCn.WTIMn bit = 0): The ACK signal is output at the falling edge of the SCL0n pin's eighth clock if the ACKEn bit is set to 1 before wait cancellation. When 9-clock wait is selected (IICCn.WTIMn bit = 1): The ACK signal is automatically output at the falling edge of the SCL0n pin's eighth clock if the ACKEn bit has already been set to 1. 484 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 17.6.5 Stop condition When the SCL0n pin is high level, changing the SDA0n pin from low level to high level generates a stop condition. A stop condition is a signal that the master device outputs to the slave device when serial transfer has been completed. When used as the slave device, the start condition can be detected. H SCL0n SDA0n Figure 17-10 Stop condition A stop condition is generated when the IICCn.SPTn bit is set to 1. When the stop condition is detected, the IICSn.SPDn bit is set to 1 and the INTIICn signal is generated when the IICCn.SPIEn bit is set to 1. User's Manual U18743EE1V2UM00 485 I2C Bus (IIC) Chapter 17 17.6.6 Wait signal (WAIT) The wait signal (WAIT) is used to notify the communication partner that a device (master or slave) is preparing to transmit or receive data (i.e., is in a wait state). Setting the SCL0n pin to low level notifies the communication partner of the wait status. When the wait status has been cancelled for both the master and slave devices, the next data transfer can begin. (1) When master device has a nine-clock wait and slave device has an eightclock wait (master: transmission, slave: reception, and IICCn.ACKEn bit = 1) Master Master returns to high Wait after output impedance but slave is in wait state (low level). of ninth clock. IICn data write (cancel wait) IICn 6 SCL0n 7 8 1 9 2 3 Slave Wait after output of eighth clock. FFH is written to IICn register or IICCn.WRELn bit is set to 1. IICn SCL0n ACKEn H Transfer lines Wait signal from master Wait signal from slave SCL0n 6 7 8 SDA0n D2 D1 D0 Figure 17-11 486 9 ACK Wait signal (1/2) User's Manual U18743EE1V2UM00 1 2 3 D7 D6 D5 I2C Bus (IIC) Chapter 17 (2) When master and slave devices both have a nine-clock wait (master: transmission, slave: reception, and ACKEn bit = 1) Master and slave both wait after output of ninth clock. IICn data write (cancel wait) Master IICn 6 SCL0n 7 8 1 9 2 3 Slave FFH is written to IICn register or WRELn bit is set to 1. IICn SCL0n ACKEn H Wait signal from master Wait signal from slave /slave Transfer lines SCL0n 6 7 8 9 SDA0n D2 D1 D0 ACK 1 D7 2 3 D6 D5 Output according to previously set ACKEn bit value Figure 17-12 Wait signal (2/2) A wait may be automatically generated depending on the setting of the IICCn.WTIMn bit. Normally, when the IICCn.WRELn bit is set to 1 or when FFH is written to the IICn register on the receiving side, the wait status is cancelled and the transmitting side writes data to the IICn register to cancel the wait status. The master device can also cancel the wait status via either of the following methods. * By setting the IICCn.STTn bit to 1 * By setting the IICCn.SPTn bit to 1 User's Manual U18743EE1V2UM00 487 I2C Bus (IIC) Chapter 17 17.7 I2C Interrupt Request Signals (INTIICn) The following shows the value of the IICSn register at the INTIICn interrupt request signal generation timing and at the INTIICn signal timing. 17.7.1 Master device operation (1) Start ~ Address ~ Data ~ Data ~ Stop (normal transmission/reception) <1> When WTIMn bit = 0 SPTn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 ACK 3 SP 4 5 1: IICSn register = 1000X110B 2: IICSn register = 1000X000B 3: IICSn register = 1000X000B (WTIMn bit = 1) 4: IICSn register = 1000XX00B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care <2> When WTIMn bit = 1 SPTn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 1: IICSn register = 1000X110B 2: IICSn register = 1000X100B 3: IICSn register = 1000XX00B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 488 User's Manual U18743EE1V2UM00 ACK SP 3 4 I2C Bus (IIC) Chapter 17 (2) Start ~ Address ~ Data ~ Start ~ Address ~ Data ~ Stop (restart) <1> When WTIMn bit = 0 ST AD6 to AD0 R/W ACK D7 to D0 1 STTn bit = 1 SPTn bit = 1 ACK 2 ST AD6 to AD0 R/W ACK 3 D7 to D0 4 ACK 5 SP 6 7 1: IICSn register = 1000X110B 2: IICSn register = 1000X000B (WTIMn bit = 1) 3: IICSn register = 1000XX00B (WTIMn bit = 0) 4: IICSn register = 1000X110B (WTIMn bit = 0) 5: IICSn register = 1000X000B (WTIMn bit = 1) 6: IICSn register = 1000XX00B 7: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 STTn bit = 1 SPTn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 ACK 1 ST AD6 to AD0 2 R/W ACK D7 to D0 3 ACK SP 4 5 1: IICSn register = 1000X110B 2: IICSn register = 1000XX00B 3: IICSn register = 1000X110B 4: IICSn register = 1000XX00B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 User's Manual U18743EE1V2UM00 489 I2C Bus (IIC) Chapter 17 (3) Start ~ Code ~ Data ~ Data ~ Stop (extension code transmission) <1> When WTIMn bit = 0 SPTn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 ACK 3 SP 4 5 1: IICSn register = 1010X110B 2: IICSn register = 1010X000B 3: IICSn register = 1010X000B (WTIMn bit = 1) 4: IICSn register = 1010XX00B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 SPTn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 1: IICSn register = 1010X110B 2: IICSn register = 1010X100B 3: IICSn register = 1010XX00B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 490 User's Manual U18743EE1V2UM00 ACK SP 3 4 I2C Bus (IIC) Chapter 17 17.7.2 Slave device operation (1) Start ~ Address ~ Data ~ Data ~ Stop <1> When WTIMn bit = 0 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 ACK SP 3 4 1: IICSn register = 0001X110B 2: IICSn register = 0001X000B 3: IICSn register = 0001X000B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 ACK SP 3 4 1: IICSn register = 0001X110B 2: IICSn register = 0001X100B 3: IICSn register = 0001XX00B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 User's Manual U18743EE1V2UM00 491 I2C Bus (IIC) Chapter 17 (2) Start ~ Address ~ Data ~ Start ~ Address ~ Data ~ Stop <1> When WTIMn bit = 0 (after restart, address match) ST AD6 to AD0 R/W ACK D7 to D0 ACK ST AD6 to AD0 R/W ACK 2 1 D7 to D0 3 ACK SP 4 5 1: IICSn register = 0001X110B 2: IICSn register = 0001X000B 3: IICSn register = 0001X110B 4: IICSn register = 0001X000B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 (after restart, address match) ST AD6 to AD0 R/W ACK D7 to D0 ACK 1 ST AD6 to AD0 2 1: IICSn register = 0001X110B 2: IICSn register = 0001XX00B 3: IICSn register = 0001X110B 4: IICSn register = 0001XX00B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 492 User's Manual U18743EE1V2UM00 R/W ACK D7 to D0 3 ACK SP 4 5 I2C Bus (IIC) Chapter 17 (3) Start ~ Address ~ Data ~ Start ~ Code ~ Data ~ Stop <1> When WTIMn bit = 0 (after restart, extension code reception) ST AD6 to AD0 R/W ACK D7 to D0 1 ACK ST AD6 to AD0 R/W 2 ACK D7 to D0 3 ACK SP 4 5 1: IICSn register = 0001X110B 2: IICSn register = 0001X000B 3: IICSn register = 0010X010B 4: IICSn register = 0010X000B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 to 2 <2> When WTIMn bit = 1 (after restart, extension code reception) ST AD6 to AD0 R/W ACK D7 to D0 ACK 1 ST AD6 to AD0 2 R/W ACK 3 D7 to D0 4 ACK SP 5 6 1: IICSn register = 0001X110B 2: IICSn register = 0001XX00B 3: IICSn register = 0010X010B 4: IICSn register = 0010X110B 5: IICSn register = 0010XX00B 6: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 to 2 User's Manual U18743EE1V2UM00 493 I2C Bus (IIC) Chapter 17 (4) Start ~ Address ~ Data ~ Start ~ Address ~ Data ~ Stop <1> When WTIMn bit = 0 (after restart, address mismatch (= not extension code)) ST AD6 to AD0 R/W ACK D7 to D0 ACK ST AD6 to AD0 R/W ACK 2 1 D7 to D0 ACK SP 3 4 1: IICSn register = 0001X110B 2: IICSn register = 0001X000B 3: IICSn register = 00000X10B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 (after restart, address mismatch (= not extension code)) ST AD6 to AD0 R/W ACK D7 to D0 ACK 1 ST AD6 to AD0 2 1: IICSn register = 0001X110B 2: IICSn register = 0001XX00B 3: IICSn register = 00000X10B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 494 User's Manual U18743EE1V2UM00 R/W ACK D7 to D0 3 ACK SP 4 I2C Bus (IIC) Chapter 17 17.7.3 Slave device operation (when receiving extension code) (1) Start ~ Code ~ Data ~ Data ~ Stop <1> When WTIMn bit = 0 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 ACK SP 3 4 1: IICSn register = 0010X010B 2: IICSn register = 0010X000B 3: IICSn register = 0010X000B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 ST R/W AD6 to AD0 ACK 1 D7 to D0 2 ACK D7 to D0 3 ACK SP 4 5 1: IICSn register = 0010X010B 2: IICSn register = 0010X110B 3: IICSn register = 0010X100B 4: IICSn register = 0010XX00B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 User's Manual U18743EE1V2UM00 495 I2C Bus (IIC) Chapter 17 (2) Start ~ Code ~ Data ~ Start ~ Address ~ Data ~ Stop <1> When WTIMn bit = 0 (after restart, address match) ST AD6 to AD0 R/W ACK D7 to D0 1 ACK ST AD6 to AD0 R/W ACK 2 D7 to D0 3 ACK SP 4 5 1: IICSn register = 0010X010B 2: IICSn register = 0010X000B 3: IICSn register = 0001X110B 4: IICSn register = 0001X000B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 (after restart, address match) ST AD6 to AD0 R/W ACK 1 D7 to D0 ACK 2 ST AD6 to AD0 3 1: IICSn register = 0010X010B 2: IICSn register = 0010X110B 3: IICSn register = 0010XX00B 4: IICSn register = 0001X110B 5: IICSn register = 0001XX00B 6: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 496 User's Manual U18743EE1V2UM00 R/W ACK D7 to D0 4 ACK SP 5 6 I2C Bus (IIC) Chapter 17 (3) Start ~ Code ~ Data ~ Start ~ Code ~ Data ~ Stop 1 2 3 4 5 1: IICSn register = 0010X010B 2: IICSn register = 0010X000B 3: IICSn register = 0010X010B 4: IICSn register = 0010X000B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 (after restart, extension code reception) 1: IICSn register = 0010X010B 2: IICSn register = 0010X110B 3: IICSn register = 0010XX00B 4: IICSn register = 0010X010B 5: IICSn register = 0010X110B 6: IICSn register = 0010XX00B 7: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 ST AD6 to AD0 R/W ACK 1 D7 to D0 2 ACK ST 3 User's Manual U18743EE1V2UM00 AD6 to AD0 R/W ACK 4 D7 to D0 5 ACK SP 6 7 497 I2C Bus (IIC) Chapter 17 (4) Start ~ Code ~ Data ~ Start ~ Address ~ Data ~ Stop <1> When WTIMn bit = 0 (after restart, address mismatch (= not extension code)) ST AD6 to AD0 R/W ACK D7 to D0 1 ACK ST AD6 to AD0 R/W ACK 2 D7 to D0 ACK SP 3 4 1: IICSn register = 0010X010B 2: IICSn register = 0010X000B 3: IICSn register = 00000X10B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 (after restart, address mismatch (= not extension code)) ST AD6 to AD0 R/W ACK 1 D7 to D0 ACK 2 ST AD6 to AD0 3 1: IICSn register = 0010X010B 2: IICSn register = 0010X110B 3: IICSn register = 0010XX00B 4: IICSn register = 00000X10B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 498 User's Manual U18743EE1V2UM00 R/W ACK D7 to D0 4 ACK SP 5 I2C Bus (IIC) Chapter 17 17.7.4 Operation without communication (1) Start ~ Code ~ Data ~ Data ~ Stop ST AD6 to AD0 R/W ACK D7 to D0 ACK D7 to D0 ACK SP 1 1: IICSn register = 00000001B Remarks 1. : Generated only when SPIEn bit = 1 2. n = 0 17.7.5 Arbitration loss operation (operation as slave after arbitration loss) (1) When arbitration loss occurs during transmission of slave address data <1> When WTIMn bit = 0 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 ACK SP 3 4 1: IICSn register = 0101X110B (Example: When ALDn bit is read during interrupt servicing) 2: IICSn register = 0001X000B 3: IICSn register = 0001X000B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 ACK SP 3 4 1: IICSn register = 0101X110B (Example: When ALDn bit is read during interrupt servicing) 2: IICSn register = 0001X100B 3: IICSn register = 0001XX00B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 User's Manual U18743EE1V2UM00 499 I2C Bus (IIC) Chapter 17 (2) When arbitration loss occurs during transmission of extension code <1> When WTIMn bit = 0 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 ACK SP 3 4 1: IICSn register = 0110X010B (Example: When ALDn bit is read during interrupt servicing) 2: IICSn register = 0010X000B 3: IICSn register = 0010X000B 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 <2> When WTIMn bit = 1 ST AD6 to AD0 R/W ACK 1 D7 to D0 2 ACK D7 to D0 3 ACK SP 4 5 1: IICSn register = 0110X010B (Example: When ALDn bit is read during interrupt servicing) 2: IICSn register = 0010X110B 3: IICSn register = 0010X100B 4: IICSn register = 0010XX00B 5: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 500 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 17.7.6 Operation when arbitration loss occurs (1) When arbitration loss occurs during transmission of slave address data ST AD6 to AD0 R/W ACK D7 to D0 ACK D7 to D0 ACK SP 1 2 1: IICSn register = 01000110B (Example: When ALDn bit is read during interrupt servicing) 2: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 2. n = 0 (2) When arbitration loss occurs during transmission of extension code ST AD6 to AD0 R/W ACK D7 to D0 ACK D7 to D0 1 1: ACK SP 2 IICSn register = 0110X010B (Example: When ALDn bit is read during interrupt servicing) IICCn.LRELn bit is set to 1 by software 2: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 User's Manual U18743EE1V2UM00 501 I2C Bus (IIC) Chapter 17 (3) When arbitration loss occurs during data transfer <1> When WTIMn bit = 0 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 ACK SP 2 3 1: IICSn register = 10001110B 2: IICSn register = 01000000B (Example: When ALDn bit is read during interrupt servicing) 3: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 2. n = 0 <2> When WTIMn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 ACK SP 3 1: IICSn register = 10001110B 2: IICSn register = 01000100B (Example: When ALDn bit is read during interrupt servicing) 3: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 2. n = 0 502 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 (4) When arbitration loss occurs due to restart condition during data transfer <1> Not extension code (Example: Address mismatch) ST AD6 to AD0 R/W ACK D7 to D0 ST AD6 to AD0 R/W ACK 1 D7 to D0 ACK SP 2 3 1: IICSn register = 1000X110B 2: IICSn register = 01000110B (Example: When ALDn bit is read during interrupt servicing) 3: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. Dn = D6 to D0 n=0 <2> Extension code ST AD6 to AD0 R/W ACK D7 to D0 ST AD6 to AD0 R/W ACK 1 D7 to D0 2 ACK SP 3 1: IICSn register = 1000X110B 2: IICSn register = 0110X010B (Example: When ALDn bit is read during interrupt servicing) IICCn.LRELn bit is set to 1 by software 3: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. Dn = D6 to D0 n=0 (5) When arbitration loss occurs due to stop condition during data transfer ST AD6 to AD0 R/W ACK D7 to D0 1 ST 2 1: IICSn register = 1000X110B 2: IICSn register = 01000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. Dn = D6 to D0 n=0 User's Manual U18743EE1V2UM00 503 I2C Bus (IIC) Chapter 17 (6) When arbitration loss occurs due to low level of SDA0n pin when attempting to generate a restart condition When WTIMn bit = 1 STTn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 ACK 1 D7 to D0 2 ACK D7 to D0 3 ACK SP 4 1: IICSn register = 1000X110B 2: IICSn register = 1000XX00B 3: IICSn register = 01000100B (Example: When ALDn bit is read during interrupt servicing) 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 (7) When arbitration loss occurs due to a stop condition when attempting to generate a restart condition When WTIMn bit = 1 STTn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK SP 2 1: IICSn register = 1000X110B 2: IICSn register = 1000XX00B 3: IICSn register = 01000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 504 User's Manual U18743EE1V2UM00 3 I2C Bus (IIC) Chapter 17 (8) When arbitration loss occurs due to low level of SDA0n pin when attempting to generate a stop condition When WTIMn bit = 1 SPTn bit = 1 ST AD6 to AD0 R/W ACK D7 to D0 1 ACK D7 to D0 2 D7 to D0 ACK 3 ACK SP 4 1: IICSn register = 1000X110B 2: IICSn register = 1000XX00B 3: IICSn register = 01000000B (Example: When ALDn bit is read during interrupt servicing) 4: IICSn register = 00000001B Remarks 1. : Always generated : Generated only when SPIEn bit = 1 X: don't care 2. n = 0 User's Manual U18743EE1V2UM00 505 I2C Bus (IIC) Chapter 17 17.8 Interrupt Request Signal (INTIICn) The setting of the IICCn.WTIMn bit determines the timing by which the INTIICn register is generated and the corresponding wait control, as shown below. Table 17-6 WTIMn Bit INTIICn generation timing and wait control During Slave Device Operation During Master Device Operation Address Data Reception Data Transmission Address Data Reception Data Transmission 0 9Notes 1, 2 8Note 2 8Note 2 9 8 8 1 9Notes 1, 2 Note 2 Note 2 9 9 9 Note 9 9 1. The slave device's INTIICn signal and wait period occur at the falling edge of the ninth clock only when there is a match with the address set to the SVAn register. At this point, the ACK signal is output regardless of the value set to the IICCn.ACKEn bit. For a slave device that has received an extension code, the INTIICn signal occurs at the falling edge of the eighth clock. When the address does not match after restart, the INTIICn signal is generated at the falling edge of the ninth clock, but no wait occurs. 2. If the received address does not match the contents of the SVAn register and an extension code is not received, neither the INTIICn signal nor a wait occurs. 3. The numbers in the table indicate the number of the serial clock's clock signals. Interrupt requests and wait control are both synchronized with the falling edge of these clock signals. (1) During address transmission/reception * Slave device operation: Interrupt and wait timing are determined regardless of the WTIMn bit. * Master device operation: Interrupt and wait timing occur at the falling edge of the ninth clock regardless of the WTIMn bit. (2) During data reception * Master/slave device operation: Interrupt and wait timing is determined according to the WTIMn bit. (3) During data transmission * Master/slave device operation: Interrupt and wait timing is determined according to the WTIMn bit. 506 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 (4) Wait cancellation method The four wait cancellation methods are as follows. Note * By setting the IICCn.WRELn bit to 1 * By writing to the IICn register * By start condition setting (IICCn.STTn bit = 1)Note * By stop condition setting (IICCn.SPTn bit = 1)Note Master only When an 8-clock wait has been selected (WTIMn bit = 0), the output level of the ACK signal must be determined prior to wait cancellation. (5) Stop condition detection The INTIICn signal is generated when a stop condition is detected. 17.9 Address Match Detection Method In I2C bus mode, the master device can select a particular slave device by transmitting the corresponding slave address. Address match detection is performed automatically by hardware. The INTIICn signal occurs when a local address has been set to the SVAn register and when the address set to the SVAn register matches the slave address sent by the master device, or when an extension code has been received. 17.10 Error Detection In I2C bus mode, the status of the serial data bus pin (SDA0n) during data transmission is captured by the IICn register of the transmitting device, so the data of the IICn register prior to transmission can be compared with the transmitted IICn data to enable detection of transmission errors. A transmission error is judged as having occurred when the compared data values do not match. User's Manual U18743EE1V2UM00 507 I2C Bus (IIC) Chapter 17 17.11 Extension Code * When the higher 4 bits of the receive address are either 0000 or 1111, the extension code flag (IICSn.EXCn bit) is set for extension code reception and an interrupt request signal (INTIICn) is issued at the falling edge of the eighth clock. The local address stored in the SVAn register is not affected. * If 11110xx0 is set to the SVAn register by a 10-bit address transfer and 11110xx0 is transferred from the master device, the results are as follows. Note that the INTIICn signal occurs at the falling edge of the eighth clock - Higher four bits of data match: EXCn bit = 1 - Seven bits of data match: IICSn.COIn bit = 1 * Since the processing after the interrupt request signal occurs differs according to the data that follows the extension code, such processing is performed by software. For example, when operation as a slave is not desired after the extension code is received, set the IICCn.LRELn bit to 1 and the CPU will enter the next communication wait state. Table 17-7 Extension code bit definitions Slave Address 508 R/W Bit Description 0000 000 0 General call address 0000 000 1 Start byte 0000 001 X CBUS address 0000 010 X Address that is reserved for different bus format 1111 0xx X 10-bit slave address specification User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 17.12 Arbitration When several master devices simultaneously output a start condition (when the IICCn.STTn bit is set to 1 before the IICSn.STDn bit is set to 1), communication between the master devices is performed while the number of clocks is adjusted until the data differs. This kind of operation is called arbitration. When one of the master devices loses in arbitration, an arbitration loss flag (IICSn.ALDn bit) is set to 1 via the timing by which the arbitration loss occurred, and the SCL0n and SDA0n lines are both set to high impedance, which releases the bus. Arbitration loss is detected based on the timing of the next interrupt request signal (the eighth or ninth clock, when a stop condition is detected, etc.) and the setting of the ALDn bit to 1, which is made by software. For details of interrupt request timing, see"I2C Interrupt Request Signals (INTIICn)" on page 488. Master 1 Hi-Z SCL0n Hi-Z SDA0n Master 1 loses arbitration Master 2 SCL0n SDA0n Transfer lines SCL0n SDA0n Figure 17-13 Arbitration timing example User's Manual U18743EE1V2UM00 509 I2C Bus (IIC) Chapter 17 Table 17-8 Status during arbitration and interrupt request signal generation timing Status During Arbitration Interrupt Request Generation Timing Transmitting address transmission At falling edge of eighth or ninth clock following byte transferNote 1 Read/write data after address transmission Transmitting extension code Read/write data after extension code transmission Transmitting data ACK signal transfer period after data reception When restart condition is detected during data transfer When stop condition is detected during data transfer When stop condition is output (when IICCn.SPIEn bit = 1)Note 2 When SDA0n pin is low level while attempting to output restart condition At falling edge of eighth or ninth clock following byte transferNote 1 When stop condition is detected while attempting to output restart condition When stop condition is output (when IICCn.SPIEn bit = 1)Note 2 When DSA0n pin is low level while attempting to output stop condition At falling edge of eighth or ninth clock following byte transferNote 1 When SCL0n pin is low level while attempting to output restart condition Note 1. When the IICCn.WTIMn bit = 1, an interrupt request signal occurs at the falling edge of the ninth clock. When the WTIMn bit = 0 and the extension code's slave address is received, an interrupt request signal occurs at the falling edge of the eighth clock. 2. When there is a possibility that arbitration will occur, set the SPIEn bit to 1 for master device operation. 17.13 Wakeup Function The I2C bus slave function is a function that generates an interrupt request signal (INTIICn) when a local address and extension code have been received. This function makes processing more efficient by preventing unnecessary interrupt request signals from occurring when addresses do not match. When a start condition is detected, wakeup stand-by mode is set. This wakeup stand-by mode is in effect while addresses are transmitted due to the possibility that an arbitration loss may change the master device (which has output a start condition) to a slave device. However, when a stop condition is detected, the IICCn.SPIEn bit is set regardless of the wakeup function, and this determines whether interrupt request signals are enabled or disabled. 510 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 17.14 Cautions (1) When IICFn.STCENn bit = 0 Immediately after the I2Cn operation is enabled, the bus communication status (IICFn.IICBSYn bit = 1) is recognized regardless of the actual bus status. To execute master communication in the status where a stop condition has not been detected, generate a stop condition and then release the bus before starting the master communication. Use the following sequence for generating a stop condition. <1> Set the IICCLn register. <2> Set the IICCn.IICEn bit. <3> Set the IICCn.SPTn bit. (2) When IICFn.STCENn bit = 1 Immediately after I2Cn operation is enabled, the bus released status (IICBSYn bit = 0) is recognized regardless of the actual bus status. To issue the first start condition (IICCn.STTn bit = 1), it is necessary to confirm that the bus has been released, so as to not disturb other communications. (3) When the IICC0.IICE0 bit of the microcontroller is set to 1 while communications with other devices are in progress, the start condition may be detected depending on the status of the communication line. Be sure to set the IICC0.IICE0 bit to 1 when the SCL00 and SDA00 lines are high level. (4) Determine the operation clock frequency by the IICCL0, IICX0, and OCKS0 registers before enabling the operation (IICC0.IICE0 bit = 1). To change the operation clock frequency, clear the IICC0.IICE0 bit to 0 once. (5) After the IICC0.STT0 and IICC0.SPT0 bits have been set to 1, they must not be re-set without being cleared to 0 first. (6) If transmission has been reserved, set the IICCN.SPIE0 bit to 1 so that an interrupt request is generated by the detection of a stop condition. After an interrupt request has been generated, the wait state will be released by writing communication data to I2C0, then transferring will begin. If an interrupt is not generated by the detection of a stop condition, transmission will halt in the wait state because an interrupt request was not generated. However, it is not necessary to set the SPIE0 bit to 1 for the software to detect the IICS0.MSTS0 bit." User's Manual U18743EE1V2UM00 511 I2C Bus (IIC) Chapter 17 17.15 Communication Operations 17.15.1 Master operation 1 The following shows the flowchart for master communication when the communication reservation function is enabled (IICFn.IICRSVn bit = 0) and the master operation is started after a stop condition is detected (IICFn.STCENn bit = 0). 512 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 START IICCLn xxH Select transfer clock IICCn xxH IICEn = SPIEn = WTIMn = SPTn = 1 INTIICn = 1? No Yes (stop condition detection) STTn = 1 Wait MSTSn = 1? Wait time is secured by software No Communication reservation Yes (start condition generation) INTIICn = 1? No Yes Stop condition detection, start condition generation by communication reservation Start IICn write transfer INTIICn = 1? No Yes ACKDn = 1? No Generate stop condition (no slave with matching address) Yes Address transfer completion TRCn = 1? No (receive) End Yes (transmit) Start IICn write transfer WTIMn = 0 ACKEn = 1 INTIICn = 1? No WRELn = 1 Start reception Yes Data processing ACKDn = 1? Yes No No (restart) INTIICn = 1? No Yes Data processing Transfer completed? Transfer completed? No Yes Generate stop condition SPTn = 1 Yes ACKEn = 0 End Figure 17-14 Master operation flowchart (1) User's Manual U18743EE1V2UM00 513 I2C Bus (IIC) Chapter 17 17.15.2 Master operation 2 The following shows the flowchart for master communication when the communication reservation function is disabled (IICRSVn bit = 1) and the master operation is started without detecting a stop condition (STCENn bit = 1). START IICCLn xxH IICFn xxH IICCn xxH IICEn = SPIEn = WTIMn = 1 IICBSYn = 0? Transfer clock selection IICFn register setting IICCn register initial setting No Yes STTn = 1 Insert wait STCFn = 0? Wait time is secured by software No Yes Start IICn write transfer INTIICn = 1? Stop master communication Master communication is stopped because bus is occupied No Yes (address transfer completion) ACKDn = 1? No (receive) Yes Generate stop condition (no slave with matching address) TRCn = 1? WTIMn = 0 ACKEn = 1 Yes (transmit) End Start IICn write transfer WRELn = 1 Start reception INTIICn = 1? No Yes INTIICn = 1? Data processing No Yes Data processing ACKDn = 1? No Yes Reception completed? Yes ACKEn = 0 No (restart) Transfer completed? Yes SPTn = 1 Generate stop condition End Figure 17-15 514 Master operation flowchart (2) User's Manual U18743EE1V2UM00 No I2C Bus (IIC) Chapter 17 17.15.3 Slave operation The following shows the processing procedure of the slave operation. Basically, the operation of the slave device is event-driven. Therefore, processing by an INTIICn interrupt (processing requiring a significant change of the operation status, such as stop condition detection during communication) is necessary. The following description assumes that data communication does not support extension codes. Also, it is assumed that the INTIICn interrupt servicing performs only status change processing and that the actual data communication is performed during the main processing. INTIICn signal Flag Interrupt servicing Setting, etc. Main processing I2C Data Setting, etc. Figure 17-16 Software outline during slave operation Therefore, the following three flags are prepared so that the data transfer processing can be performed by transmitting these flags to the main processing instead of INTIICn signal. (1) Communication mode flag This flag indicates the following communication statuses. * Clear mode: Data communication not in progress * Communication mode Data communication in progress (valid address detection stop condition detection, ACK signal from master not detected, address mismatch) (2) Ready flag This flag indicates that data communication is enabled. This is the same status as an INTIICn interrupt during normal data transfer. This flag is set in the interrupt processing block and cleared in the main processing block. The ready flag for the first data for transmission is not set in the interrupt processing block, so the first data is transmitted without clear processing (the address match is regarded as a request for the next data). User's Manual U18743EE1V2UM00 515 I2C Bus (IIC) Chapter 17 (3) Communication direction flag This flag indicates the direction of communication and is the same as the value of IICSn.TRCn bit. The following shows the operation of the main processing block during slave operation. Start I2Cn and wait for the communication enabled status. When communication is enabled, perform transfer using the communication mode flag and ready flag (the processing of the stop condition and start condition is performed by interrupts, conditions are confirmed by flags). For transmission, repeat the transmission operation until the master device stops returning ACK signal. When the master device stops returning ACK signal, transfer is complete. For reception, receive the required number of data and do not return ACK signal for the next data immediately after transfer is complete. After that, the master device generates the stop condition or restart condition. This causes exit from communications. 516 User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 START IICCLn XXH Selection of transfer flag IICFn XXH IICFn register setting IICCn XXH IICEn = 1 No Communication mode? Yes Communication direction flag = 1? No ACKEn = WTIMn = 1 Yes WRELn = 1 WTIMn = 1 No Communication mode? Data processing Yes No Ready? IICn data Yes No Read data Communication mode? Yes No Clear ready flag Ready? Yes Data processing Clear ready flag No ACKDn = 1? Yes No Transfer completed? Yes WRELn = 1 ACKEn = 0 Clear communication mode flag WRELn = 1 Figure 17-17 Slave operation flowchart (1) The following shows an example of the processing of the slave device by an INTIICn interrupt (it is assumed that no extension codes are used here). User's Manual U18743EE1V2UM00 517 I2C Bus (IIC) Chapter 17 During an INTIICn interrupt, the status is confirmed and the following steps are executed. <1> When a stop condition is detected, communication is terminated. <2> When a start condition is detected, the address is confirmed. If the address does not match, communication is terminated. If the address matches, the communication mode is set and wait is released, and operation returns from the interrupt (the ready flag is cleared). <3> For data transmission/reception, when the ready flag is set, operation returns from the interrupt while the IIC0n bus remains in the wait status. Note <1> to <3> in the above correspond to <1> to <3> in Figure 17-18. INTIICn generated Yes <1> Yes <2> SPDn = 1? No STDn = 1? No No COIn = 1? <3> Yes Set ready flag Communication direction flag TRCn Set communication mode flag Clear ready flag Interrupt servicing completed Interrupt servicing completed Termination processing LRELn = 1 Clear communication mode Interrupt servicing completed Figure 17-18 518 Slave operation flowchart (2) User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 17.16 Timing of Data Communication When using I2C bus mode, the master device outputs an address via the serial bus to select one of several slave devices as its communication partner. After outputting the slave address, the master device transmits the IICSn.TRCn bit, which specifies the data transfer direction, and then starts serial communication with the slave device. The shift operation of the IICn register is synchronized with the falling edge of the serial clock pin (SCL0n). The transmit data is transferred to the SO latch and is output (MSB first) via the SDA0n pin. Data input via the SDA0n pin is captured by the IICn register at the rising edge of the SCL0n pin. The data communication timing is shown below. User's Manual U18743EE1V2UM00 519 I2C Bus (IIC) Chapter 17 Processing by master device IICn address IICn IICn data ACKDn STDn SPDn WTIMn H ACKEn H MSTSn STTn SPTn WRELn L L INTIICn TRCn H Transmit Transfer lines 1 SCL0n 2 3 4 5 6 7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 SDA0n 8 9 1 2 3 4 W ACK D7 D6 D5 D4 Start condition Processing by slave device IICn FFH IICn Note ACKDn STDn SPDn WTIMn H ACKEn H MSTSn L STTn L SPTn L Note WRELn INTIICn (When EXCn = 1) TRCn L Receive Figure 17-19 Note 520 Example of master to slave communication (when 9-clock wait is selected for both master and slave) (1/3) start condition ~ address To cancel slave wait, write FFH to IICn or set WRELn. User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 Processing by master device IICn data IICn IICn data ACKDn STDn L SPDn L WTIMn H ACKEn H MSTSn H STTn L SPTn L WRELn L INTIICn TRCn H Transmit Transfer lines SCL0n 8 9 SDA0n D0 1 2 3 4 5 6 7 8 D7 D6 D5 D4 D3 D2 D1 D0 9 1 2 3 D7 D6 D5 Processing by slave device IICn FFH Note IICn IICn FFH Note ACKDn STDn L SPDn L WTIMn H ACKEn H MSTSn L STTn L SPTn L Note WRELn Note INTIICn TRCn L Receive Figure 17-20 Note Example of master to slave communication (when 9-clock wait is selected for both master and slave) (2/3) (b) data To cancel slave wait, write FFH to IICn or set WRELn. User's Manual U18743EE1V2UM00 521 I2C Bus (IIC) Chapter 17 Processing by master device IICn data IICn IICn address ACKDn STDn SPDn WTIMn H ACKEn H MSTSn STTn SPTn WRELn L INTIICn (When SPIEn = 1) TRCn H Transmit Transfer lines SCL0n 1 2 3 4 5 6 7 8 SDA0n D7 D6 D5 D4 D3 D2 D1 D0 Processing by slave device IICn FFH Note IICn 9 1 2 AD6 AD5 Stop condition Start condition IICn FFH Note ACKDn STDn SPDn WTIMn H ACKEn H MSTSn L STTn L SPTn L Note WRELn Note INTIICn (When SPIEn = 1) TRCn L Receive Figure 17-21 Note 522 Example of master to slave communication (when 9-clock wait is selected for both master and slave) (3/3) (c) stop condition To cancel slave wait, write FFH to IICn or set WRELn. User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 Processing by master device IICn address IICn IICn FFH Note ACKDn STDn SPDn WTIMn H ACKEn H MSTSn STTn SPTn L Note WRELn INTIICn TRCn Transfer lines 1 SCL0n 2 3 4 5 6 7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 SDA0n 8 R 9 1 D7 2 3 4 5 6 D6 D5 D4 D3 D2 Start condition Processing by slave device IICn data IICn ACKDn STDn SPDn WTIMn H ACKEn H MSTSn L STTn L SPTn L WRELn L INTIICn TRCn Figure 17-22 Note Example of slave to master communication (when 9-clock wait is selected for both master and slave) (1/3) (a) start condition ~ address To cancel master wait, write FFH to IICn or set WRELn. User's Manual U18743EE1V2UM00 523 I2C Bus (IIC) Chapter 17 Processing by master device IICn FFH Note IICn IICn FFH Note ACKDn STDn L SPDn L WTIMn H ACKEn H MSTSn H STTn L SPTn L Note WRELn Note INTIICn TRCn L Receive Transfer lines SCL0n 8 9 SDA0n D0 ACK 1 D7 2 3 4 5 6 7 8 9 D6 D5 D4 D3 D2 D1 D0 ACK 1 D7 2 3 D6 D5 Processing by slave device IICn data IICn IICn data ACKDn STDn L SPDn L WTIMn H ACKEn H MSTSn L STTn L SPTn L WRELn L INTIICn TRCn H Transmit Figure 17-23 Note 524 Example of slave to master communication (when 9-clock wait is selected for both master and slave) (2/3) (b) data To cancel master wait, write FFH to IICn or set WRELn. User's Manual U18743EE1V2UM00 I2C Bus (IIC) Chapter 17 Processing by master device IICn FFH Note IICn IICn address ACKDn STDn SPDn WTIMn H ACKEn MSTSn STTn SPTn Note WRELn INTIICn (When SPIEn = 1) TRCn Transfer lines 1 SCL0n 2 3 4 5 6 7 D7D6D5D4D3D2D1D0AD5 SDA0n 8 9 2 1 N- ACK Stop condition AD6 Start condition Processing by slave device IICn data IICn ACKDn STDn SPDn WTIMn H ACKEn H MSTSn L STTn L SPTn L WRELn INTIICn (When SPIEn = 1) TRCn Figure 17-24 Note Example of slave to master communication (when 9-clock wait is selected for both master and slave) (3/3) (c) stop condition To cancel master wait, write FFH to IICn or set WRELn. User's Manual U18743EE1V2UM00 525 I2C Bus (IIC) Chapter 17 526 User's Manual U18743EE1V2UM00 Chapter 18 CAN Controller (CAN) These microcontrollers feature an on-chip n-channel CAN (Controller Area Network) controller that complies with the CAN protocol as standardized in ISO 11898. The number of CAN channels is given in the table below: CAN V850ES/FE3-L V850ES/FF3-L Channels Names V850ES/FG3-L 1 CAN0 Throughout this chapter, the individual channels of CAN are identified by "n", for example, C0GMCTRL for the CAN0 global control register. Throughout this chapter, the CAN message buffer registers are identified by "m" (m = 0 to 31), for example C0MDATA4m for CAN0 message data byte 4 of message buffer register m. User's Manual U18743EE1V2UM00 527 Chapter 18 CAN Controller (CAN) 18.1 Features * Compliant with ISO 11898 and tested according to ISO/DIS 16845 (CAN conformance test) * Standard frame and extended frame transmission/reception enabled * Transfer rate: 1 Mbps max. (if CAN clock input 8 MHz, for 32 channels) * 32 message buffers per channel * Receive/transmit history list function * Automatic block transmission function * Multi-buffer receive block function * Mask setting of four patterns is possible for each channel * Data bit time, communication baud rate and sample point can be controlled by CAN module bit-rate prescaler register (CnBRP) and bit rate register (CnBTR) - As an example the following sample-point configurations can be configured: - 66.7%, 70.0%, 75.0%, 80.0%, 81.3%, 85.0%, 87.5% - Baud rates in the range of 10 kbps up to 1000 kbps can be configured * Enhanced features: - Each message buffer can be configured to operate as a transmit or a receive message buffer - Transmission priority is controlled by the identifier or by mailbox number (selectable) - A transmission request can be aborted by clearing the dedicated Transmit-Request flag of the concerned message buffer. - Automatic block transmission operation mode (ABT) - Time stamp function for CAN channels 0 to n in collaboration with timers TAA0 to TAAn capture channels 528 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.1.1 Overview of functions Table 18-1 presents an overview of the CAN Controller functions. Table 18-1 Overview of functions Function Details Protocol CAN protocol ISO 11898 (standard and extended frame transmission/reception) Baud rate Maximum 1 Mbps (CAN clock input 8 MHz) Data storage Storing messages in the CAN RAM Number of messages * 32 message buffers per channel * Each message buffer can be set to be either a transmit message buffer or a receive message buffer. Message reception * Unique ID can be set to each message buffer. * Mask setting of four patterns is possible for each channel. * A receive completion interrupt is generated each time a message is received and stored in a message buffer. * Two or more receive message buffers can be used as a FIFO receive buffer (multi-buffer receive block function). * Receive history list function Message transmission * Unique ID can be set to each message buffer. * Transmit completion interrupt for each message buffer * Message buffer number 0 to 7 specified as the transmit message buffer can be set for automatic block transfer. Message transmission interval is programmable (automatic block transmission function (hereafter referred to as "ABT")). * Transmission history list function Remote frame processing Remote frame processing by transmit message buffer Time stamp function * The time stamp function can be set for a message reception when a 16-bit timer is used in combination. * Time stamp capture trigger can be selected (SOF or EOF in a CAN message frame can be detected.). * The time stamp function can be set for a transmit message. Diagnostic function * * * * * * Readable error counters "Valid protocol operation flag" for verification of bus connections Receive-only mode Single-shot mode CAN protocol error type decoding Self-test mode Release from bus-off state * Forced release from bus-off (by ignoring timing constraint) possible by software. * No automatic release from bus-off (software must re-enable). Power save mode * CAN Sleep mode (can be woken up by CAN bus) * CAN Stop mode (cannot be woken up by CAN bus) User's Manual U18743EE1V2UM00 529 Chapter 18 CAN Controller (CAN) 18.1.2 Configuration The CAN Controller is composed of the following four blocks. * NPB interface This functional block provides an NPB (NEC Peripheral I/O Bus) interface and means of transmitting and receiving signals between the CAN module and the host CPU. * MCM (Memory Control Module) This functional block controls access to the CAN protocol layer and to the CAN RAM within the CAN module. * CAN protocol layer This functional block is involved in the operation of the CAN protocol and its related settings. * CAN RAM This is the CAN memory functional block, which is used to store message IDs, message data, etc. CPU Interrupt request INTCnTRX INTCnREC INTCnERR INTCnWUP NPB (NEC Peripheral I/O Bus) CAN bus NPB interface MCM (Message Control Module) CAN Protocol Layer CAN RAM Message buffer 0 Message buffer 1 Message buffer 2 Message buffer 3 fCAN Note ... TSOUTCn CnMASK1 CnMASK2 CnMASK3 CnMASK4 Message buffer m CAN module Note: The CAN input clock can be chosen from - the main oscillator clock fXC - the peripheral clock fXP1 Refer to chapter "Clock Generator" for f CAN selection control. Figure 18-1 530 Block diagram of CAN module User's Manual U18743EE1V2UM00 CTXDn CRXDn CAN transceiver CAN_H CAN_L CAN Controller (CAN) Chapter 18 18.2 CAN Protocol CAN (Controller Area Network) is a high-speed multiplex communication protocol for real-time communication in automotive applications (class C). CAN is prescribed by ISO 11898. For details, refer to the ISO 11898 specifications. The CAN specification is generally divided into two layers: a physical layer and a data link layer. In turn, the data link layer includes logical link and medium access control. The composition of these layers is illustrated below. * Logical link control (LLC) Higher Data link layerNote Lower * Medium access control (MAC) Physical layer Figure 18-2 Note * Acceptance filtering * Overload report * Recovery management * Data capsuled/not capsuled * Frame coding (stuffing/no stuffing) * Medium access management * Error detection * Error report * Acknowledgement * Seriated/not seriated Prescription of signal level and bit description Composition of layers CAN Controller specification 18.2.1 Frame format (1) Standard format frame * The standard format frame uses 11-bit identifiers, which means that it can handle up to 2,048 messages. (2) Extended format frame * The extended format frame uses 29-bit (11 bits + 18 bits) identifiers, which increases the number of messages that can be handled to 2,048 x 218 messages. * An extended format frame is set when "recessive level" (CMOS level of "1") is set for both the SRR and IDE bits in the arbitration field. User's Manual U18743EE1V2UM00 531 Chapter 18 CAN Controller (CAN) 18.2.2 Frame types The following four types of frames are used in the CAN protocol. Table 18-2 (1) Frame types Frame Type Description Data frame Frame used to transmit data Remote frame Frame used to request a data frame Error frame Frame used to report error detection Overload frame Frame used to delay the next data frame or remote frame Bus value The bus values are divided into dominant and recessive. * Dominant level is indicated by logical 0. * Recessive level is indicated by logical 1. * When a dominant level and a recessive level are transmitted simultaneously, the bus value becomes dominant level. 18.2.3 Data frame and remote frame (1) Data frame A data frame is composed of seven fields. Data frame R D <1> <2> <3> <4> <5> <6> <7> <8> Interframe space End of frame (EOF) ACK field CRC field Data field Control field Arbitration field Start of frame (SOF) Figure 18-3 Note 532 Data frame D: Dominant = 0 R: Recessive = 1 User's Manual U18743EE1V2UM00 CAN Controller (CAN) (2) Chapter 18 Remote frame A remote frame is composed of six fields. Remote frame R D <1> <2> <3> <5> <6> <7> <8> Interframe space End of frame (EOF) ACK field CRC field Control field Arbitration field Start of frame (SOF) Figure 18-4 Note Remote frame 1. The data field is not transferred even if the control field's data length code is not "0000B". 2. D: Dominant = 0 R: Recessive = 1 (3) Description of fields (a) Start of frame (SOF) The start of frame field is located at the start of a data frame or remote frame. (Interframe space or bus idle) Start of frame (Arbitration field) R D 1 bit Figure 18-5 Note Start of frame (SOF) D: Dominant = 0 R: Recessive = 1 * If dominant level is detected in the bus idle state, a hard-synchronization is performed (the current TQ is assigned to be the SYNC segment). * If dominant level is sampled at the sample point following such a hard-synchronization, the bit is assigned to be a SOF. If recessive level is detected, the protocol layer returns to the bus idle state and regards the preceding dominant pulse as a disturbance only. No error frame is generated in such case. User's Manual U18743EE1V2UM00 533 Chapter 18 CAN Controller (CAN) (b) Arbitration field The arbitration field is used to set the priority, data frame/remote frame, and frame format. Arbitration field (Control field) R D Identifier RTR ID28 * * * * * * * * * * * * * * * * * * * * * * * * * * ID18 (11 bits) (1 bit) Figure 18-6 Caution IDE (r1) r0 (1 bit) Arbitration field (in standard format mode) 1. ID28 to ID18 are identifiers. 2. An identifier is transmitted MSB first. Note D: Dominant = 0 R: Recessive = 1 Arbitration field (Control field) R D Identifier SRR IDE Identifier RTR r1 r0 ID17 * * * * * * * * * * * * * * * * * * * * * * ID0 ID28 * * * * * * * * * * * * * * * * * * * ID18 (11 bits) (1 bit) (1 bit) (18 bits) (1 bit) Figure 18-7 Caution Arbitration field (in extended format mode) 1. ID28 to ID18 are identifiers. 2. An identifier is transmitted MSB first. Note Table 18-3 Table 18-4 534 D: Dominant = 0 R: Recessive = 1 RTR frame settings Frame type RTR bit Data frame 0 (D) Remote frame 1 (R) Frame format setting (IDE bit) and number of identifier (ID) bits Frame format SRR bit IDE bit Number of bits Standard format mode None 0 (D) 11 bits Extended format mode 1 (R) 1 (R) 29 bits User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 (c) Control field The control field sets "DLC" as the number of data bytes in the data field (DLC = 0 to 8). (Arbitration field) Control field (Data field) R D RTR Figure 18-8 Note r1 (IDE) r0 DLC3 DLC2 DLC1 DLC0 Control field D: Dominant = 0 R: Recessive = 1 In a standard format frame, the control field's IDE bit is the same as the r1 bit. Table 18-5 Data length setting Data length code DLC3 DLC2 DLC1 DLC0 0 0 0 0 0 bytes 0 0 0 1 1 byte 0 0 1 0 2 bytes 0 0 1 1 3 bytes 0 1 0 0 4 bytes 0 1 0 1 5 bytes 0 1 1 0 6 bytes 0 1 1 1 7 bytes 1 0 0 0 8 bytes Other than above Caution Data byte count 8 bytes regardless of the value of DLC3 to DLC0 In the remote frame, there is no data field even if the data length code is not 0000B. User's Manual U18743EE1V2UM00 535 Chapter 18 CAN Controller (CAN) (d) Data field The data field contains the amount of data (byte units) set by the control field. Up to 8 units of data can be set. (Control field) Data field (CRC field) R D Data 0 (8 bits) MSB Figure 18-9 Note LSB Data 7 (8 bits) MSB LSB Data field D: Dominant = 0 R: Recessive = 1 (e) CRC field The CRC field is a 16-bit field that is used to check for errors in transmit data. (Data field or control field) CRC field (ACK field) R D CRC sequence (15 bits) Figure 18-10 Note CRC delimiter (1 bit) CRC field D: Dominant = 0 R: Recessive = 1 * The polynomial P(X) used to generate the 15-bit CRC sequence is expressed as follows. P(X) = X15 + X14 + X10 + X8 + X7 + X4 + X3 + 1 536 * Transmitting node: Transmits the CRC sequence calculated from the data (before bit stuffing) in the start of frame, arbitration field, control field, and data field. * Receiving node: Compares the CRC sequence calculated using data bits that exclude the stuffing bits in the receive data with the CRC sequence in the CRC field. If the two CRC sequences do not match, the node issues an error frame. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 (f) ACK field The ACK field is used to acknowledge normal reception. (CRC field) ACK field (End of frame) R D ACK slot (1 bit) Figure 18-11 Note ACK delimiter (1 bit) ACK field D: Dominant = 0 R: Recessive = 1 * If no CRC error is detected, the receiving node sets the ACK slot to the dominant level. * The transmitting node outputs two recessive-level bits. (g) End of frame (EOF) The end of frame field indicates the end of data frame/remote frame. (ACK field) End of frame (Interframe space or overload frame) R D (7 bits) Figure 18-12 Note End of frame (EOF) D: Dominant = 0 R: Recessive = 1 (h) Interframe space The interframe space is inserted after a data frame, remote frame, error frame, or overload frame to separate one frame from the next. * The bus state differs depending on the error status. - Error active node The interframe space consists of a 3-bit intermission field and a bus idle field. (Frame) Interframe space (Frame) R D Intermission (3 bits) Figure 18-13 Bus idle (0 to bits) Interframe space (error active node) User's Manual U18743EE1V2UM00 537 Chapter 18 CAN Controller (CAN) Note 1. Bus idle: State in which the bus is not used by any node. 2. D: Dominant = 0 R: Recessive = 1 - Error passive node The interframe space consists of an intermission field, a suspend transmission field, and a bus idle field. (Frame) Interframe space R D Suspend transmission (8 bits) Intermission (3 bits) Figure 18-14 Note (Frame) Bus idle (0 to bits) Interframe space (error passive node) 1. Bus idle: Suspend transmission: State in which the bus is not used by any node. Sequence of 8 recessive-level bits transmitted from the node in the error passive status. 2. D: Dominant = 0 R: Recessive = 1 Usually, the intermission field is 3 bits. If the transmitting node detects a dominant level at the third bit of the intermission field, however, it executes transmission. * Operation in error status Table 18-6 538 Operation in error status Error status Operation Error active A node in this status can transmit immediately after a 3-bit intermission. Error passive A node in this status can transmit 8 bits after the intermission. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.2.4 Error frame An error frame is output by a node that has detected an error. Error frame R D (<4>) <1> <2> <3> 6 bits 0 to 6 bits 8 bits (<5>) Interframe space or overload frame Error delimiter Error flag 2 Error flag 1 Error bit Figure 18-15 Note Table 18-7 No. Name <1> Error flag 1 Error frame D: Dominant = 0 R: Recessive = 1 Definition of error frame fields Bit count 6 Definition Error active node: Error passive node: Outputs 6 dominant-level bits consecutively. Outputs 6 recessive-level bits consecutively. If another node outputs a dominant level while one node is outputting a passive error flag, the passive error flag is not cleared until the same level is detected 6 bits in a row. <2> Error flag 2 0 to 6 Nodes receiving error flag 1 detect bit stuff errors and issues this error flag. <3> Error delimiter 8 Outputs 8 recessive-level bits consecutively. If a dominant level is detected at the 8th bit, an overload frame is transmitted from the next bit. <4> Error bit - The bit at which the error was detected. The error flag is output from the bit next to the error bit. In the case of a CRC error, this bit is output following the ACK delimiter. <5> Interframe space/ overload frame - An interframe space or overload frame starts from here. User's Manual U18743EE1V2UM00 539 Chapter 18 CAN Controller (CAN) 18.2.5 Overload frame An overload frame is transmitted under the following conditions. * When the receiving node has not completed the reception operation * If a dominant level is detected at the first two bits during intermission * If a dominant level is detected at the last bit (7th bit) of the end of frame or at the last bit (8th bit) of the error delimiter/overload delimiter Note The CAN is internally fast enough to process all received frames not generating overload frames. Overload frame R D (<4>) <1> <2> <3> 6 bits 0 to 6 bits 8 bits (<5>) Interframe space or overload frame Overload delimiter Overload flag Overload flag Frame Figure 18-16 Overload frame Note D: Dominant = 0 R: Recessive = 1 Table 18-8 No Name <1> Overload flag <2> Definition of overload frame fields Bit count Definition 6 Overload flag from other node 0 to 6 The node that received an overload flag in the interframe space outputs an overload flag. 8 Outputs 8 recessive-level bits consecutively. If a dominant level is detected at the 8th bit, an overload frame is transmitted from the next bit. - Output following an end of frame, error delimiter, or overload delimiter. Overload delimiter <3> <4> <5> 540 Frame Interframe space/overload frame Outputs 6 dominant-level bits consecutively. - An interframe space or overload frame starts from here. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.3 Functions 18.3.1 Determining bus priority (1) When a node starts transmission: * During bus idle, the node that output data first transmits the data. (2) When more than one node starts transmission: * The node that consecutively outputs the dominant level for the longest from the first bit of the arbitration field has the bus priority (if a dominant level and a recessive level are simultaneously transmitted, the dominant level is taken as the bus value). * The transmitting node compares its output arbitration field and the data level on the bus. Table 18-9 (3) Determining bus priority Level match Continuous transmission Level mismatch Stops transmission at the bit where mismatch is detected and starts reception at the following bit Priority of data frame and remote frame * When a data frame and a remote frame are on the bus, the data frame has priority because its RTR bit, the last bit in the arbitration field, carries a dominant level. Note If the extended-format data frame and the standard-format remote frame conflict on the bus (if ID28 to ID18 of both of them are the same), the standard-format remote frame takes priority. 18.3.2 Bit stuffing Bit stuffing is used to establish synchronization by appending 1 bit of inverted-level data if the same level continues for 5 bits, in order to prevent a burst error. Table 18-10 Bit stuffing Transmission During the transmission of a data frame or remote frame, when the same level continues for 5 bits in the data between the start of frame and the ACK field, 1 inverted-level bit of data is inserted before the following bit. Reception During the reception of a data frame or remote frame, when the same level continues for 5 bits in the data between the start of frame and the ACK field, reception is continued after deleting the next bit. User's Manual U18743EE1V2UM00 541 Chapter 18 CAN Controller (CAN) 18.3.3 Multi masters As the bus priority (a node acquiring transmit functions) is determined by the identifier, any node can be the bus master. 18.3.4 Multi cast Although there is one transmitting node, two or more nodes can receive the same data at the same time because the same identifier can be set to two or more nodes. 18.3.5 CAN sleep mode/CAN stop mode function The CAN sleep mode/CAN stop mode function puts the CAN Controller in waiting mode to achieve low power consumption. The controller is woken up from the CAN sleep mode by bus operation but it is not woken up from the CAN stop mode by bus operation (the CAN stop mode is controlled by CPU access). 18.3.6 Error control function (1) Error types Table 18-11 Error types Description of error Type Detection method Detection state Detection condition Transmission/ reception Field/frame Bit error Comparison of the output level and level on the bus (except stuff bit) Mismatch of levels Transmitting/ receiving node Bit that is outputting data on the bus at the start of frame to end of frame, error frame and overload frame. Stuff error Check of the receive data at the stuff bit 6 consecutive bits of the same output level Receiving node Start of frame to CRC sequence CRC error Comparison of the CRC sequence generated from the receive data and the received CRC sequence Mismatch of CRC Receiving node CRC field Form error Field/frame check of the fixed format Detection of fixed format violation Receiving node CRC delimiter ACK field End of frame Error frame Overload frame ACK error Check of the ACK slot by the transmitting node Detection of recessive level in ACK slot Transmitting node ACK slot 542 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 (2) Output timing of error frame Table 18-12 Output timing of error frame (3) Type Output timing Bit error, stuff error, form error, ACK error Error frame output is started at the timing of the bit following the detected error. CRC error Error frame output is started at the timing of the bit following the ACK delimiter. Processing in case of error The transmission node re-transmits the data frame or remote frame after the error frame. (However, it does not re-transmit the frame in the single-shot mode.) (4) Error state (a) Types of error states The following three types of error states are defined by the CAN specification: * Error active * Error passive * Bus-off These types of error states are classified by the values of the TEC7 to TEC0 bits (transmission error counter bits) and the REC6 to REC0 bits (reception error counter bits) as shown in Table 18-13. The present error state is indicated by the CAN module information register (CnINFO). When each error counter value becomes equal to or greater than the error warning level (96), the TECS0 or RECS0 bit of the CnINFO register is set to 1. In this case, the bus state must be tested because it is considered that the bus has a serious fault. An error counter value of 128 or more indicates an error passive state and the TECS1 or RECS1 bit of the CnINFO register is set to 1. * If the value of the transmission error counter is greater than or equal to 256 (actually, the transmission error counter does not indicate a value greater than or equal to 256), the bus-off state is reached and the BOFF bit of the CnINFO register is set to 1. * If only one node is active on the bus at startup (i.e., a particular case such as when the bus is connected only to the local station), ACK is not returned even if data is transmitted. Consequently, re-transmission of the error frame and data is repeated. In the error passive state, however, the transmission error counter is not incremented and the bus-off state is not reached. User's Manual U18743EE1V2UM00 543 Chapter 18 CAN Controller (CAN) Table 18-13 Types of error states Type Operation Value of error counter Indication of CnINFO register Error active Transmission 0 to 95 TECS1, TECS0 = 00 Reception 0 to 95 RECS1, RECS0 = 00 Transmission 96 to 127 TECS1, TECS0 = 01 Reception 96 to 127 RECS1, RECS0 = 01 Transmission 128 to 255 TECS1, TECS0 = 11 Reception 128 or more RECS1, RECS0 = 11 Transmission 256 or more (not indicated) Note BOFF = 1, TECS1, TECS0 = 11 Error passive Bus-off Note 544 Operation specific to error state Outputs an active error flag (6 consecutive dominant-level bits) on detection of the error. Outputs a passive error flag (6 consecutive recessive-level bits) on detection of the error. Transmits 8 recessive-level bits, in between transmissions, following an intermission (suspend transmission). Communication is not possible. Messages are not stored when receiving frames, however, the following operations of <1>, <2>, and <3> are done. <1> TSOUT toggles. <2> REC is incremented/decremented. <3> VALID bit is set. If the CAN module is entered to the initialization mode and then transition request to any operation mode is made, and when 11 consecutive recessive-level bits are detected 128 times, the error counter is reset to 0 and the error active state can be restored. The value of the transmission error counter (TEC) is invalid when the BOFF bit is set to 1. If an error that increments the value of the transmission error counter by +8 while the counter value is in a range of 248 to 255, the counter is not incremented and the bus-off state is assumed. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 (b) Error counter The error counter counts up when an error has occurred, and counts down upon successful transmission and reception. The error counter is updated immediately after error detection. Table 18-14 Error counter Transmission error counter (TEC7 to TEC0 bits) Reception error counter (REC6 to REC0 bits) Receiving node detects an error (except bit error in the active error flag or overload flag). No change +1 (when REPS = 0) Receiving node detects dominant level following error flag of error frame. No change +8 (when REPS = 0) State Transmitting node transmits an error flag. +8 [As exceptions, the error counter does not change in the following cases.] <1> ACK error is detected in error passive state and dominant level is not detected while the passive error flag is being output. <2> A stuff error is detected in an arbitration field that transmitted a recessive level as a stuff bit, but a dominant level is detected. No change Bit error detection while active error flag or overload flag is being output (error-active transmitting node) +8 No change Bit error detection while active error flag or overload flag is being output (error-active receiving node) No change +8 (REPS bit = 0) When the node detects 14 consecutive dominant-level bits from the beginning of the active error flag or overload flag, and then subsequently detects 8 consecutive dominant-level bits. When the node detects 8 consecutive dominant levels after a passive error flag +8 (transmitting) +8 (during reception, when REPS = 0) When the transmitting node has completed transmission without error (0 if error counter = 0) -1 No change When the receiving node has completed reception without error No change * -1 (1 REC6 to REC0 127, when REPS = 0) * 0 (REC6 to REC0 = 0, when REPS = 0) * Value of 119 to 127 is set (when REPS = 1) (c) Occurrence of bit error in intermission An overload frame is generated. Caution If an error occurs, it is controlled according to the contents of the transmission error counter and reception error counter before the error occurred. The value of the error counter is incremented after the error flag has been output. User's Manual U18743EE1V2UM00 545 Chapter 18 CAN Controller (CAN) (5) Recovery from bus-off state When the CAN module is in the bus-off state, the CAN module permanently sets its output signals (CTXDn) to recessive level. The CAN module recovers from the bus-off state in the following bus-off recovery sequence. 1. A request to enter the CAN initialization mode 2. A request to enter a CAN operation mode (a)Recovery operation through normal recovery sequence (b)Forced recovery operation that skips recovery sequence (a) Recovery from bus-off state through normal recovery sequence The CAN module first issues a request to enter the initialization mode (refer too timing <1> in Figure 18-17 on page 547). This request will be immediately acknowledged, and the OPMODE bits of the CnCTRL. register are cleared to 000B. Processing such as analyzing the fault that has caused the bus-off state, re-defining the CAN module and message buffer using application software, or stopping the operation of the CAN module can be performed by clearing the GOM bit to 0. Next, the module requests to change the mode from the initialization mode to an operation mode (refer to timing <2> in Figure 18-17 on page 547). This starts an operation to recover the CAN module from the bus-off state. The conditions under which the module can recover from the bus-off state are defined by the CAN protocol ISO 11898, and it is necessary to detect 11 consecutive recessive-level bits 128 times. At this time, the request to change the mode to an operation mode is held pending until the recovery conditions are satisfied. When the recovery conditions are satisfied (refer to timing <3> in Figure 18-17 on page 547), the CAN module can enter the operation mode it has requested. Until the CAN module enters this operation mode, it stays in the initialization mode. Completion to be requested operation mode can be confirmed by reading the OPMODE bits of the CnCTRL register. During the bus-off period and bus-off recovery sequence, the BOFF bit of the CnINFO register stays set (to 1). In the bus-off recovery sequence, the reception error counter (REC[6:0]) counts the number of times 11 consecutive recessive-level bits have been detected on the bus. Therefore, the recovery state can be checked by reading REC[6:0]. Caution 1. In the bus-off recovery sequence, REC[6:0] counts up (+1) each time 11 consecutive recessive-level bits have been detected. Even during the bus-off period, the CAN module can enter the CAN sleep mode or CAN stop mode. To start the bus-off recovery sequence, it is necessary to transit to the initialization mode once. However, when the CAN module is in either CAN sleep mode or CAN stop mode, transition request to the initialization mode is not accepted, thus you have to release the CAN sleep mode first. In this case, as soon as the CAN sleep mode is released, the bus-off recovery sequence starts and no transition to initialization mode is necessary. If the can module detects a dominant edge on the CAN bus while in sleep mode even during bus-off, the sleep mode will be left and the bus-off recovery sequence will start. 2. During the bus-off recovery sequence, when the request to change the mode from the initialization mode to an operation mode is generated to execute the buss-off recovery sequence again, the reception error counter (REC [6:0]) is cleared. In this case, it is required to detect 11 consecutive recessive-level bits 128 times again on the bus. 546 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 TEC > FFH bus-off error-passive bus-off-recovery-sequence error-active BOFF bit in CnINFO register <1> OPMODE[2:0] in CnCTRL register (user writings) 00H OPMODE[2:0] in CnCTRL register (user readings) 00H Figure 18-17 00H 00H <3> TEC[7:0] in CnERC 80H TEC[7:0] FFH register REPS, REC[6:0] in CnERC register <2> 00H 00H FFH < TEC [7:0] 00H REPS, REC[6:0] 80H 00H Undefined 00H TEC[7:0] < 80H 00H REPS, REC[6:0] < 80H Recovery from bus-off state through normal recovery sequence (b) Forced recovery operation that skips bus-off recovery sequence The CAN module can be forcibly released from the bus-off state, regardless of the bus state, by skipping the bus-off recovery sequence. Here is the procedure. First, the CAN module requests to enter the initialization mode. For the operation and points to be noted at this time, "Recovery from bus-off state through normal recovery sequence" on page 546. Next, the module requests to enter an operation mode. At the same time, the CCERC bit of the CnCTRL register must be set to 1. As a result, the bus-off recovery sequence defined by the CAN protocol ISO 11898 is skipped, and the module immediately enters the operation mode. In this case, the module is connected to the CAN bus after it has monitored 11 consecutive recessive-level bits. For details, refer to the processing in Figure 18-54 on page 656. Caution This function is not defined by the CAN protocol ISO 11898. When using this function, thoroughly evaluate its effect on the network system. User's Manual U18743EE1V2UM00 547 Chapter 18 CAN Controller (CAN) (6) Initializing CAN module error counter register (CnERC) in initialization mode If it is necessary to initialize the CAN module error counter register (CnERC) and CAN module information register (CnINFO) for debugging or evaluating a program, they can be initialized to the default value by setting the CCERC bit of the CnCTRL register in the initialization mode. When initialization has been completed, the CCERC bit is automatically cleared to 0. Caution 1. This function is enabled only in the initialization mode. Even if the CCERC bit is set to 1 in a CAN operation mode, the CnERC and CnINFO registers are not initialized. 2. The CCERC bit can be set at the same time as the request to enter a CAN operation mode. 548 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.3.7 Baud rate control function (1) Prescaler The CAN controller has a prescaler that divides the clock (fCAN) supplied to CAN. This prescaler generates a CAN protocol layer basic system clock (fTQ) derived from the CAN module system clock (fCANMOD), and divided by 1 to 256 ("CnBRP - CANn module bit rate prescaler register" on page 580). (2) Data bit time (8 to 25 time quanta) One data bit time is defined as shown in Figure 18-18 on page 549. The CAN Controller sets time segment 1, time segment 2, and reSynchronization Jump Width (SJW) of data bit time, as shown in Figure 18-18. Time segment 1 is equivalent to the total of the propagation (prop) segment and phase segment 1 that are defined by the CAN protocol specification. Time segment 2 is equivalent to phase segment 2. Data bit time(DBT) Sync segment Prop segment Phase segment 1 Time segment 1(TSEG1) Phase segment 2 Time segment 2 (TSEG2) Sample point (SPT) Figure 18-18 Segment setting Table 18-15 Segment setting Segment name Settable range Notes on setting to conform to CAN specification Time segment 1 (TSEG1) 2TQ to 16TQ - Time segment 2 (TSEG2) 1TQ to 8TQ IPT of the CAN controller is 0TQ. To conform to the CAN protocol specification, therefore, a length less or equal to phase segment 1 must be set here. This means that the length of time segment 1 minus 1TQ is the settable upper limit of time segment 2. Resynchronization Jump Width (SJW) 1TQ to 4TQ The length of time segment 1 minus 1TQ or 4 TQ, whichever is smaller. Note 1. IPT: Information Processing Time 2. TQ: Time Quanta Reference: The CAN protocol specification defines the segments constituting the data bit time as shown in Figure 18-19. User's Manual U18743EE1V2UM00 549 Chapter 18 CAN Controller (CAN) Data bit time(DBT) Sync segment Prop segment Phase segment 1 Phase segment 2 SJW Sample point (SPT) Figure 18-19 Configuration of data bit time defined by CAN specification Table 18-16 Configuration of data bit time defined by CAN specification Notes on setting to conform to CAN specification Segment name Settable range Sync segment (Synchronization segment) 1 This segment starts at the edge where the level changes from recessive to dominant when hardware synchronization is established. Prop segment Programmable to 1 to 8 or more This segment absorbs the delay of the output buffer, CAN bus, and input buffer. Phase segment 1 Programmable to 1 to 8 Phase segment 2 Phase segment 1 or IPT, whichever greater The length of this segment is set so that ACK is returned before the start of phase segment 1. Time of prop segment (Delay of output buffer) + 2 x (Delay of CAN bus) + (Delay of input buffer) This segment compensates for an error of data bit time. The longer this segment, the wider the permissible range but the slower the communication speed. SJW Programmable from 1TQ to length of segment 1 or 4TQ, whichever is smaller Note 550 This width sets the upper limit of expansion or contraction of the phase segment during resynchronization. IPT: Information Processing Time User's Manual U18743EE1V2UM00 CAN Controller (CAN) (3) Chapter 18 Synchronizing data bit * The receiving node establishes synchronization by a level change on the bus because it does not have a sync signal. * The transmitting node transmits data in synchronization with the bit timing of the transmitting node. (a) Hardware synchronization This synchronization is established when the receiving node detects the start of frame in the interframe space. * When a falling edge is detected on the bus, that TQ means the sync segment and the next segment is the prop segment. In this case, synchronization is established regardless of SJW. Interframe space Start of frame CAN bus Sync segment Bit timing Figure 18-20 Prop segment Phase segment 1 Phase segment 2 Adjusting synchronization of data bit (b) Resynchronization Synchronization is established again if a level change is detected on the bus during reception (only if a recessive level was sampled previously). * The phase error of the edge is given by the relative position of the detected edge and sync segment. <Sign of phase error> 0: If the edge is within the sync segment Positive: If the edge is before the sample point (phase error) Negative: If the edge is after the sample point (phase error) If phase error is positive: Phase segment 1 is lengthened by specified SJW. If phase error is negative: Phase segment 2 is shortened by specified SJW. * The sample point of the data of the receiving node moves relatively due to the "discrepancy" in the baud rate between the transmitting node and receiving node. User's Manual U18743EE1V2UM00 551 Chapter 18 CAN Controller (CAN) If phase error is positive CAN bus Bit timing Sync segment Prop segment Phase segment 2 Phase segment 1 Sample point If phase error is negative CAN bus Bit timing Sync segment Prop segment Phase segment 1 Phase segment 2 Sample point Figure 18-21 Resynchronization 18.4 Connection with Target System The CAN module has to be connected to the CAN bus using an external transceiver. CTxDn CAN module Figure 18-22 552 Connection to CAN bus User's Manual U18743EE1V2UM00 CRxDn CANL Transceiver CANH CAN Controller (CAN) Chapter 18 18.5 Internal Registers of CAN Controller 18.5.1 CAN module register and message buffer addresses In this chapter all register and message buffer addresses are defined as address offsets to different base addresses. Since all registers are accessed via the programmable peripheral area the bottom address is defined by the BPC register (refer to "Programmable peripheral I/O area" on page 153 or to "Programmable peripheral I/O area (PPA)" on page 297). The addresses given in the following tables are offsets to the programmable peripheral area base address PBA. The setting of BPC is fixed to 8FFBH. This setting defines the programmable peripheral area base address PBA = 03FE C000H Table 18-17 lists all base addresses used throughout this chapter. Table 18-17 CAN module base addresses Base address name Base address of Address Address for BPC =8FFBH C0RBaseAddr CAN0 registers PBA + 000H 03FE C000H C0MBaseAddr CAN0 message buffers PBA + 100H 03FE C100H In the following <CnRBaseAddr> respectively <CnMBaseAddr> are used for the base address names for CAN channel n. User's Manual U18743EE1V2UM00 553 Chapter 18 CAN Controller (CAN) 18.5.2 CAN Controller configuration Table 18-18 List of CAN Controller registers Item Register Name CAN global registers CANn global control register (CnGMCTRL) CANn global clock selection register (CnGMCS) CANn global automatic block transmission control register (CnGMABT) CANn global automatic block transmission delay setting register (CnGMABTD) CAN module registers CANn module mask 1 register (CnMASK1L, CnMASK1H) CANn module mask 2 register (CnMASK2L, CnMASK2H) CANn module mask 3 register (CnMASK3L, CnMASK3H) CANn module mask 4 registers (CnMASK4L, CnMASK4H) CANn module control register (CnCTRL) CANn module last error information register (CnLEC) CANn module information register (CnINFO) CANn module error counter register (CnERC) CANn module interrupt enable register (CnIE) CANn module interrupt status register (CnINTS) CANn module bit rate prescaler register (CnBRP) CANn module bit rate register (CnBTR) CANn module last in-pointer register (CnLIPT) CANn module receive history list register (CnRGPT) CANn module last out-pointer register (CnLOPT) CANn module transmit history list register (CnTGPT) CANn module time stamp register (CnTS) Message buffer registers CANn message data byte 01 register m (CnMDATA01m) CANn message data byte 0 register m (CnMDATA0m) CANn message data byte 1 register m (CnMDATA1m) CANn message data byte 23 register m (CnMDATA23m) CANn message data byte 2 register m (CnMDATA2m) CANn message data byte 3 register m (CnMDATA3m) CANn message data byte 45 register m (CnMDATA45m) CANn message data byte 4 register m (CnMDATA4m) CANn message data byte 5 register m (CnMDATA5m) CANn message data byte 67 register m (CnMDATA67m) CANn message data byte 6 register m (CnMDATA6m) CANn message data byte 7 register m (CnMDATA7m) CANn message data length register m (CnMDLCm) CANn message configuration register m (CnMCONFm) CANn message ID register m (CnMIDLm, CnMIDHm) CANn message control register m (CnMCTRLm) 554 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.5.3 CAN registers overview (1) CAN0 module registers The following table lists the address offsets to the CAN0 register base address: C0RBaseAddr = PBA Table 18-19 Address offset CAN0 global and module registers Register name Symbol R/W R/W Access 1-bit 8-bit 16-bit After reset 000 H CAN0 global control register C0GMCTRL 002 H CAN0 global clock selection register C0GMCS 006 H CAN0 global automatic block transmission register C0GMABT 008 H CAN0 global automatic block transmission delay register C0GMABTD 040 H CAN0 module mask 1 register C0MASK1L Undefined C0MASK1H Undefined C0MASK2L Undefined C0MASK2H Undefined C0MASK3L Undefined C0MASK3H Undefined C0MASK4L Undefined C0MASK4H Undefined 0000 H 042 H 044 H CAN0 module mask 2 register 046 H 048 H CAN0 module mask 3 register 04A H 04C H CAN0 module mask 4 register 04E H CAN0 module control register C0CTRL 052 H CAN0 module last error code register C0LEC 053 H CAN0 module information register C0INFO 054 H CAN0 module error counter register C0ERC 056 H CAN0 module interrupt enable register C0IE 058 H CAN0 module interrupt status register C0INTS 05A H CAN0 module bit-rate prescaler register C0BRP 05C H CAN0 module bit-rate register C0BTR 05E H CAN0 module last in-pointer register C0LIPT R 060 H CAN0 module receive history list register C0RGPT R/W 062 H CAN0 module last out-pointer register C0LOPT R 064 H CAN0 module transmit history list register C0TGPT R/W 066 H CAN0 module time stamp register C0TS User's Manual U18743EE1V2UM00 0F H 050 H R 0000 H 0000 H 00 H 00 H 00 H R/W 0000 H 0000 H 0000 H FF H 370F H Undefined xx02 H Undefined xx02 H 0000 H 555 Chapter 18 CAN Controller (CAN) The addresses in the following table denote the address offsets to the CAN #n message buffer base address: CnMBaseAddr, with m being the message buffer number. Example CAN0, message buffer m = 14 = EH, byte 6 C0MDATA614 has the address EH x 20H + 6H + C0MBaseAddr Note The message buffer register number m in the register symbols has 2 digits, for example, C0MDATA01m = C0MDATA0100 for m = 0. Table 18-20 Address offset CAN0 message buffer registers Access Symbol R/W CAN #n message data byte 01 register m CnMDATA01m R/W mx20 H + 0 H CAN #n message data byte 0 register m CnMDATA0m Undefined mx20 H + 1 H CAN #n message data byte 1 register m CnMDATA1m Undefined CAN #n message data byte 23 register m CnMDATA23m mx20 H + 2 H CAN #n message data byte 2 register m CnMDATA2m Undefined mx20 H + 3 H CAN #n message data byte 3 register m CnMDATA3m Undefined CAN #n message data byte 45 register m CnMDATA45m mx20 H + 4 H CAN #n message data byte 4 register m CnMDATA4m Undefined mx20 H + 5 H CAN #n message data byte 5 register m CnMDATA5m Undefined CAN #n message data byte 67 register m CnMDATA67m mx20 H + 6 H CAN #n message data byte 6 register m CnMDATA6m Undefined mx20 H + 7 H CAN #n message data byte 7 register m CnMDATA7m Undefined mx20 H + 8 H CAN #n message data length register m CnMDLCm 0000 xxxx B mx20 H + 9 H CAN #n message configuration register m CnMCONFm Undefined mx20 H + A H CAN #n message identifier register m CnMIDLm Undefined CnMIDHm Undefined CnMCTRLm 0x00 0000 0000 0000 B mx20 H + 0 H mx20 H + 2 H mx20 H + 4 H mx20 H + 6 H Register name mx20 H + C H mx20 H + E H 556 CAN #n message control register m User's Manual U18743EE1V2UM00 1-bit 8-bit 16-bit After reset Undefined Undefined Undefined Undefined CAN Controller (CAN) Chapter 18 18.5.4 Register bit configuration Table 18-21 CAN global register bit configuration Address offseta Symbol Bit 7/15 Bit 6/14 Bit 5/13 Bit 4/12 Bit 3/11 Bit 2/10 Bit 1/9 Bit 0/8 00 H CnGMCTRL (W) 0 0 0 0 0 0 0 Clear GOM 0 0 0 0 0 0 Set EFSD Set GOM 0 0 0 0 0 0 EFSD GOM MBON 0 0 0 0 0 0 0 01 H CnGMCTRL (R) 00 H 01 H 02 H CnGMCS 0 0 0 0 CCP3 CCP2 CCP1 CCP0 06 H CnGMABT (W) 0 0 0 0 0 0 0 Clear ABTTRG 0 0 0 0 0 0 Set ABTCLR Set ABTTRG 0 0 0 0 0 0 ABTCLR ABTTRG 0 0 0 0 0 0 0 0 0 0 0 0 ABTD3 ABTD2 ABTD1 ABTD0 Bit 2/10 Bit 1/9 Bit 0/8 07 H 06 H CnGMABT (R) 07 H 08 H a) CnGMABTD Base address: <CnRBaseAddr> Table 18-22 Address offseta Symbol 40 H CnMASK1L CAN module register bit configuration (1/2) Bit 7/15 Bit 6/14 Bit 5/13 CMID15 to CMID8 CnMASK1H 43 H 44 H CMID23 to CMID16 0 0 0 CnMASK2L CMID15 to CMID8 CnMASK2H 47 H 48 H CMID23 to CMID16 0 0 0 CnMASK3L CMID15 to CMID8 CnMASK3H CMID23 to CMID16 0 4B H 4C H 0 0 CnMASK4L CMID15 to CMID8 CnMASK4H 4F H 50 H CnCTRL (W) 51 H 50 H 51 H CMID28 to CMID24 CMID7 to CMID0 4D H 4E H CMID28 to CMID24 CMID7 to CMID0 49 H 4A H CMID28 to CMID24 CMID7 to CMID0 45 H 46 H Bit 3/11 CMID7 to CMID0 41 H 42 H Bit 4/12 CnCTRL (R) CMID23 to CMID16 0 0 0 0 Clear AL Clear VALID Clear PSMODE1 Clear PSMODE0 Clear OPMODE2 Clear OPMODE1 Clear OPMODE0 Set CCERC Set AL 0 Set PSMODE1 Set PSMODE0 Set OPMODE2 Set OPMODE1 Set OPMODE0 CCERC AL VALID PS MODE1 PS MODE0 OP MODE2 OP MODE1 OP MODE0 0 0 0 0 0 0 RSTAT TSTAT User's Manual U18743EE1V2UM00 CMID28 to CMID24 557 Chapter 18 CAN Controller (CAN) Table 18-22 CAN module register bit configuration (2/2) Address offseta Symbol Bit 7/15 Bit 6/14 Bit 5/13 Bit 4/12 Bit 3/11 Bit 2/10 Bit 1/9 Bit 0/8 52 H CnLEC (W) 0 0 0 0 0 0 0 0 52 H CnLEC (R) 0 0 0 0 0 LEC2 LEC1 LEC0 53 H CnINFO 0 0 0 BOFF TECS1 TECS0 RECS1 RECS0 54 H CnERC 55 H 56 H REPS CnIE (W) 57 H 56 H CnIE (R) 57 H 58 H CnINTS (W) 59 H 58 H CnINTS (R) 59 H 5A H CnBRP 5C H CnBTR 5D H 5E H CnLIPT 60 H CnRGPT (W) 61 H 60 H TEC7 to TEC0 CnRGPT (R) REC6 to REC0 0 0 Clear CIE5 Clear CIE4 Clear CIE3 Clear CIE2 Clear CIE1 Clear CIE0 0 0 Set CIE5 Set CIE4 Set CIE3 Set CIE2 Set CIE1 Set CIE0 0 0 CIE5 CIE4 CIE3 CIE2 CIE1 CIE0 0 0 0 0 0 0 0 0 0 0 Clear CINTS5 Clear CINTS4 Clear CINTS3 Clear CINTS2 Clear CINTS1 Clear CINTS0 0 0 0 0 0 0 0 0 0 0 CINTS5 CINTS4 CINTS3 CINTS2 CINTS1 CINTS0 0 0 0 0 0 0 0 0 TQPRS7 to TQPRS0 0 0 0 0 0 SJW1, SJW0 CnLOPT 64 H CnTGPT (W) 65 H CnTGPT (R) 0 0 0 0 0 0 Clear ROVF 0 0 0 0 0 0 0 0 0 0 0 0 0 0 RHPM ROVF LOPT7 to LOPT0 0 0 0 0 0 0 0 Clear TOVF 0 0 0 0 0 0 0 0 0 0 0 0 0 0 THPM TOVF TGPT7 to TGPT0 CnTS (W) 67 H CnTS (R) 67 H 68 H to FF H a) 558 TSEG22 to TSEG20 0 65 H 66 H 0 RGPT7 to RGPT0 F62 H 66 H TSEG13 to TSEG10 LIPT7 to LIPT0 61 H 64 H 0 0 0 0 0 0 Clear TSLOCK Clear TSSEL Clear TSEN 0 0 0 0 0 Set TSLOCK Set TSSEL Set TSEN 0 0 0 0 0 TSLOCK TSSEL TSEN 0 0 0 0 0 0 0 0 - Access prohibited (reser ved for future use) Base address: <CnRBaseAddr> User's Manual U18743EE1V2UM00 CAN Controller (CAN) Table 18-23 Address offseta Symbol 0H CnMDATA01m Chapter 18 Message buffer register bit configuration Bit 7/15 Bit 6/14 Bit 5/13 Bit 3/11 Bit 2/10 Bit 1/9 Bit 0/8 MDLC3 MDLC2 MDLC1 MDLC0 Message data (byte 0) Message data (byte 1) 1H 0H CnMDATA0m Message data (byte 0) 1H CnMDATA1m Message data (byte 1) 2H CnMDATA23m Message data (byte 2) 3H Message data (byte 3) 2H CnMDATA2m Message data (byte 2) 3H CnMDATA3m Message data (byte 3) 4H CnMDATA45m Message data (byte 4) 5H Message data (byte 5) 4H CnMDATA4m Message data (byte 4) 5H CnMDATA5m Message data (byte 5) 6H CnMDATA67m Message data (byte 6) Message data (byte 7) 7H 6H CnMDATA6m Message data (byte 6) 7H CnMDATA7m Message data (byte 7) 8H CnMDLCm 9H CnMCONFm OWS RTR MT2 MT1 MT0 0 0 MA0 AH CnMIDLm ID7 ID6 ID5 ID4 ID3 ID2 ID1 ID0 ID15 ID14 ID13 ID12 ID11 ID10 ID9 ID8 ID23 ID22 ID21 ID20 ID19 ID18 ID17 ID16 IDE 0 0 ID28 ID27 ID26 ID25 ID24 0 0 0 Clear MOW Clear IE Clear DN Clear TRQ Clear RDY 0 0 0 0 Set IE 0 Set TRQ Set RDY 0 0 0 MOW IE DN TRQ RDY 0 0 MUC 0 0 0 0 0 BH CH CnMIDHm DH EH CnMCTRLm (W) FH EH FH a) Bit 4/12 CnMCTRLm (R) 0 Base address: <CnMBaseAddr> Note For calculation of the complete message buffer register addresses refer to "CAN registers overview" on page 555. User's Manual U18743EE1V2UM00 559 Chapter 18 CAN Controller (CAN) 18.6 Bit Set/Clear Function The CAN control registers include registers whose bits can be set or cleared via the CPU and via the CAN interface. An operation error occurs if the following registers are written directly. Do not write any values directly via bit manipulation, read/modify/write, or direct writing of target values. * CANn global control register (CnGMCTRL) * CANn global automatic block transmission control register (CnGMABT) * CANn module control register (CnCTRL) * CANn module interrupt enable register (CnIE) * CANn module interrupt status register (CnINTS) * CANn module receive history list register (CnRGPT) * CANn module transmit history list register (CnTGPT) * CANn module time stamp register (CnTS) * CANn message control register (CnMCTRLm) All the 16 bits in the above registers can be read via the usual method. Use the procedure described in Figure 18-23 below to set or clear the lower 8 bits in these registers. Setting or clearing of lower 8 bits in the above registers is performed in combination with the higher 8 bits (refer to the bit status after set/clear operation is specified in Figure 18-26). Figure 18-23 shows how the values of set bits or clear bits relate to set/clear/no change operations in the corresponding register. 560 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 1 1 0 1 0 0 0 1 Write value 0 0 0 0 1 0 1 1 1 1 0 1 1 0 0 0 set 0 0 0 0 1 0 1 1 clear 1 1 0 1 1 0 0 0 Register's value after write operation Figure 18-23 (1) 0 0 0 0 0 0 0 Set 0 Set 0 No change 0 No change 0 Clear 0 No change 0 Clear 0 Clear 0 Bit status Register's current value 0 0 0 0 0 0 0 1 1 Example of bit setting/clearing operations Bit status after bit setting/clearing operations 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Set 7 Set 6 Set 5 Set 4 Set 3 Set 2 Set 1 Set 0 Clear 7 Clear 6 Clear 5 Clear 4 Clear 3 Clear 2 Clear 1 Clear 0 Set 0 ... 7 Clear 0 ... 7 0 0 No change 0 1 0 1 0 1 1 1 No change User's Manual U18743EE1V2UM00 Status of bit n after bit set/clear operation 561 Chapter 18 CAN Controller (CAN) 18.7 Control Registers (1) CnGMCTRL - CANn global control register The CnGMCTRL register is used to control the operation of the CAN module. Access Address Initial Value This register can be read/written in 16-bit units. <CnRBaseAddr> + 000H 0000H. The register is initialized by any reset. (a) CnGMCTRL read 15 14 13 12 11 10 9 8 MBON 0 0 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 EFSD GOM MBON Caution Bit enabling access to message buffer register, transmit/receive history registers 0 Write access and read access to the message buffer register and the transmit/receive history list registers is disabled. 1 Write access and read access to the message buffer register and the transmit/receive history list registers is enabled. 1. While the MBON bit is cleared (to 0), software access to the message buffers (CnMDATA0m, CnMDATA1m, CnMDATA01m, CnMDATA2m, CnMDATA3m, CnMDATA23m, CnMDATA4m, CnMDATA5m, CnMDATA45m, CnMDATA6m, CnMDATA7m, CnMDATA67m, CnMDLCm, CnMCONFm, CnMIDLm, CnMIDHm, and CnMCTRLm), or registers related to transmit history or receive history (CnLOPT, CnTGPT, CnLIPT, and CnRGPT) is disabled. 2. This bit is read-only. Even if 1 is written to the MBON bit while it is 0, the value of the MBON bit does not change, and access to the message buffer registers, or registers related to transmit history or receive history remains disabled. Note The MBON bit is cleared (to 0) when the CAN module enters CAN sleep mode/ CAN stop mode, or when the GOM bit is cleared (to 0). The MBON bit is set (to 1) when the CAN sleep mode/CAN stop mode is released, or when the GOM bit is set (to 1). EFSD 562 Bit enabling forced shut down 0 Forced shut down by GOM bit = 0 disabled. 1 Forced shut down by GOM bit = 0 enabled. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Caution Chapter 18 To request forced shut down, the GOM bit must be cleared to 0 in a subsequent, immediately following access after the EFSD bit has been set to 1. If access to another register (including reading the CnGMCTRL register) is executed without clearing the GOM bit immediately after the EFSD bit has been set to 1, the EFSD bit is forcibly cleared to 0, and the forced shut down request is invalid. GOM Caution Global operation mode bit 0 CAN module is disabled from operating. 1 CAN module is enabled to operate. The GOM can be cleared only in the initialization mode or immediately after EFSD bit is set (to 1). (b) CnGMCTRL write 15 14 13 11 10 9 8 Set GOM 0 0 0 0 0 0 Set EFSD 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 Clear GOM Set EFSD EFSD bit setting 0 No change in EFSD bit. 1 EFSD bit set to 1. Set GOM Clear GOM 0 1 GOM bit cleared to 0. 1 0 GOM bit set to 1. Other than above Caution 12 GOM bit setting No change in GOM bit. Set the GOM bit and EFSD bit always separately. User's Manual U18743EE1V2UM00 563 Chapter 18 CAN Controller (CAN) (2) CnGMCS - CANn global clock selection register The CnGMCS register is used to select the CAN module system clock. Access Address Initial Value Note 564 This register can be read/written in 8-bit units. <CnRBaseAddr> + 002H 0FH. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 0 CCP3 CCP2 CCP1 CCP0 CCP3 CCP2 CCP1 CCP1 0 0 0 0 fCAN/1 0 0 0 1 fCAN/2 0 0 1 0 fCAN/3 0 0 1 1 fCAN/4 0 1 0 0 fCAN/5 0 1 0 1 fCAN/6 0 1 1 0 fCAN/7 0 1 1 1 fCAN/8 1 0 0 0 fCAN/9 1 0 0 1 fCAN/10 1 0 1 0 fCAN/11 1 0 1 1 fCAN/12 1 1 0 0 fCAN/13 1 1 0 1 fCAN/14 1 1 1 0 fCAN/15 1 1 1 1 fCAN/16 (default value) fCAN = clock supplied to CAN User's Manual U18743EE1V2UM00 CAN module system clock (fCANMOD) CAN Controller (CAN) (3) Chapter 18 CnGMABT - CANn global automatic block transmission control register The CnGMABT register is used to control the automatic block transmission (ABT) operation. Access Address Initial Value This register can be read/written in 16-bit units. <CnRBaseAddr> + 006H 0000H. The register is initialized by any reset. (a) CnGMABT read Note 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 ABTCLR ABTTRG ABTCLR Automatic block transmission engine clear status bit 0 Clearing the automatic transmission engine is completed. 1 The automatic transmission engine is being cleared. 1. Set the ABTCLR bit to 1 while the ABTTRG bit is cleared to 0. The operation is not guaranteed if the ABTCLR bit is set to 1 while the ABTTRG bit is set to 1. 2. When the automatic block transmission engine is cleared by setting the ABTCLR bit to 1, the ABTCLR bit is automatically cleared to 0 as soon as the requested clearing processing is complete. ABTTRG Caution Automatic block transmission status bit 0 Automatic block transmission is stopped. 1 Automatic block transmission is under execution. 1. Do not set the ABTTRG bit (1) in the initialization mode. If the ABTTRG bit is set in the initialization mode, the operation is not guaranteed after the CAN module has entered the normal operation mode with ABT. 2. Do not set the ABTTRG bit (1) while the CnCTRL.TSTAT bit is set (1). Confirm TSTAT = 0 directly in advance before setting ABTTRG bit. User's Manual U18743EE1V2UM00 565 Chapter 18 CAN Controller (CAN) (b) CnGMABT write Caution 15 14 13 12 11 10 0 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 Clear ABTTRG 8 Set Set ABTCLR ABTTRG Before changing the normal operation mode with ABT to the initialization mode, be sure to set the CnGMABT register to the default value (0000H) and confirm the CnGMABT register is surely initialized to the default value (0000H). Set ABTCLR Automatic block transmission engine clear request bit 0 The automatic block transmission engine is in idle status or under operation. 1 Request to clear the automatic block transmission engine. After the automatic block transmission engine has been cleared, automatic block transmission is started from message buffer 0 by setting the ABTTRG bit to 1. Set ABTTRG Clear ABTTRG Automatic block transmission start bit 0 1 Request to stop automatic block transmission. 1 0 Request to start automatic block transmission. Other than above 566 9 User's Manual U18743EE1V2UM00 No change in ABTTRG bit. CAN Controller (CAN) (4) Chapter 18 CnGMABTD - CANn global automatic block transmission delay register The CnGMABTD register is used to set the interval at which the data of the message buffer assigned to ABT is to be transmitted in the normal operation mode with ABT. Access Address Initial Value This register can be read/written in 8-bit units. <CnRBaseAddr> + 008H 00H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 0 ABTD3 ABTD2 ABTD1 ABTD0 ABTD2 ABTD1 ABTD0 0 0 0 0 0 DBT (default value) 0 0 0 1 25 DBT 0 0 1 0 26 DBT 0 0 1 1 27 DBT 0 1 0 0 28 DBT 0 1 0 1 29 DBT 0 1 1 0 210 DBT 0 1 1 1 211 DBT 1 0 0 0 212 DBT Other than above a) Caution Data frame interval during automatic block transmission in DBTa ABTD3 Setting prohibited Unit: Data bit time (DBT) 1. Do not change the contents of the CnGMABTD register while the ABTTRG bit is set to 1. 2. The timing at which the ABT message is actually transmitted onto the CAN bus differs depending on the status of transmission from the other station or how a request to transmit a message other than an ABT message (message buffers 8 to 31) is made. User's Manual U18743EE1V2UM00 567 Chapter 18 CAN Controller (CAN) (5) CnMASKaL, CnMASKaH - CANn module mask control register (a = 1 to 4) The CnMASKaL and CnMASKaH registers are used to extend the number of receivable messages into the same message buffer by masking part of the identifier (ID) comparison of a message and invalidating the ID of the masked part. (a) CANn module mask 1 register (CnMASK1L, CnMASK1H) Access Address Initial Value These registers can be read/written in 16-bit units. CnMASK1L: <CnRBaseAddr> + 040H CnMASK1H: <CnRBaseAddr> + 042H Undefined. CnMASK1L 15 14 13 12 11 10 9 8 CMID15 CMID14 CMID13 CMID12 CMID11 CMID10 CMID9 CMID8 7 6 5 4 3 2 1 0 CMID7 CMID6 CMID5 CMID4 CMID3 CMID2 CMID1 CMID0 15 14 13 12 11 10 9 8 0 0 0 CMID28 CMID27 CMID26 CMID25 CMID24 7 6 5 4 3 2 1 0 CMID23 CMID22 CMID21 CMID20 CMID19 CMID18 CMID17 CMID16 CnMASK1H (b) CANn module mask 2 register (CnMASK2L, CnMASK2H) Access Address Initial Value These registers can be read/written in 16-bit units. CnMASK2L: <CnRBaseAddr> + 044H CnMASK2H: <CnRBaseAddr> + 046H Undefined. CnMASK2L 15 14 13 12 11 10 9 8 CMID15 CMID14 CMID13 CMID12 CMID11 CMID10 CMID9 CMID8 7 6 5 4 3 2 1 0 CMID7 CMID6 CMID5 CMID4 CMID3 CMID2 CMID1 CMID0 15 14 13 12 11 10 9 8 0 0 0 CMID28 CMID27 CMID26 CMID25 CMID24 7 6 5 4 3 2 1 0 CMID23 CMID22 CMID21 CMID20 CMID19 CMID18 CMID17 CMID16 CnMASK2H 568 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 (c) CANn module mask 3 register (CnMASK3L, CnMASK3H) Access Address Initial Value These registers can be read/written in 16-bit units. CnMASK3L: <CnRBaseAddr> + 048H CnMASK3H: <CnRBaseAddr> + 04AH Undefined. CnMASK3L 15 14 13 12 11 10 9 8 CMID15 CMID14 CMID13 CMID12 CMID11 CMID10 CMID9 CMID8 7 6 5 4 3 2 1 0 CMID7 CMID6 CMID5 CMID4 CMID3 CMID2 CMID1 CMID0 15 14 13 12 11 10 9 8 0 0 0 CMID28 CMID27 CMID26 CMID25 CMID24 7 6 5 4 3 2 1 0 CMID23 CMID22 CMID21 CMID20 CMID19 CMID18 CMID17 CMID16 CnMASK3H (d) CANn module mask 4 register (CnMASK4L, CnMASK4H) Access Address Initial Value These registers can be read/written in 16-bit units. CnMASK4L: <CnRBaseAddr> + 04CH CnMASK4H: <CnRBaseAddr> + 04EH Undefined. CnMASK4L 15 14 13 12 11 10 9 8 CMID15 CMID14 CMID13 CMID12 CMID11 CMID10 CMID9 CMID8 7 6 5 4 3 2 1 0 CMID7 CMID6 CMID5 CMID4 CMID3 CMID2 CMID1 CMID0 15 14 13 12 11 10 9 8 0 0 0 CMID28 CMID27 CMID26 CMID25 CMID24 CnMASK4H CMID28 to CMID0 7 6 5 4 3 2 1 0 CMID23 CMID22 CMID21 CMID20 CMID19 CMID18 CMID17 CMID16 Mask pattern setting of ID bit 0 The ID bits of the message buffer set by the CMID28 to CMID0 bits are compared with the ID bits of the received message frame. 1 The ID bits of the message buffer set by the CMID28 to CMID0 bits are not compared with the ID bits of the received message frame (they are masked). Note Masking is always defined by an ID length of 29 bits. If a mask is assigned to a message with a standard ID, the CMID17 to CMID0 bits are ignored. Therefore, only the CMID28 to CMID18 bits of the received ID are masked. The same mask can be used for both the standard and extended IDs. User's Manual U18743EE1V2UM00 569 Chapter 18 CAN Controller (CAN) (6) CnCTRL - CANn module control register The CnCTRL register is used to control the operation mode of the CAN module. Access Address Initial Value This register can be read/written in 16-bit units. <CnRBaseAddr> + 050H 0000H. The register is initialized by any reset. (a) CnCTRL read Note 15 14 13 12 11 10 9 8 0 0 0 0 0 0 RSTAT TSTAT 7 6 5 4 3 2 1 0 CCERC AL VALID PSMODE1 PSMODE0 OPMODE2 OPMODE1 OPMODE0 RSTAT Reception status bit 0 Reception is stopped. 1 Reception is in progress. 1. The RSTAT bit is set to 1 under the following conditions (timing) * The SOF bit of a receive frame is detected * On occurrence of arbitration loss during a transmit frame 2. The RSTAT bit is cleared to 0 under the following conditions (timing) * When a recessive level is detected at the second bit of the interframe space * On transition to the initialization mode at the first bit of the interframe space Note TSTAT Transmission status bit 0 Transmission is stopped. 1 Transmission is in progress. 1. The TSTAT bit is set to 1 under the following conditions (timing) * The SOF bit of a transmit frame is detected 2. The TSTAT bit is cleared to 0 under the following conditions (timing) * During transition to bus-off state * On occurrence of arbitration loss in transmit frame * On detection of recessive level at the second bit of the interframe space * On transition to the initialization mode at the first bit of the interframe space 570 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 CCERC Note Error counter clear bit 0 The CnERC and CnINFO registers are not cleared in the initialization mode. 1 The CnERC and CnINFO registers are cleared in the initialization mode. 1. The CCERC bit is used to clear the CnERC and CnINFO registers for re-initialization or forced recovery from the bus-off state. This bit can be set to 1 only in the initialization mode. 2. When the CnERC and CnINFO registers have been cleared, the CCERC bit is also cleared to 0 automatically. 3. The CCERC bit can be set to 1 at the same time as a request to change the initialization mode to an operation mode is made. 4. The CCERC bit is read-only in the CAN sleep mode or CAN stop mode. 5. The receive data may be corrupted in case of setting the CCERC bit to (1) immediately after entering the INIT mode from self-test mode. AL Note 0 Re-transmission is not executed in case of an arbitration loss in the single-shot mode. 1 Re-transmission is executed in case of an arbitration loss in the single-shot mode. The AL bit is valid only in the single-shot mode. VALID Note Bit to set operation in case of arbitration loss Valid receive message frame detection bit 0 A valid message frame has not been received since the VALID bit was last cleared to 0. 1 A valid message frame has been received since the VALID bit was last cleared to 0. 1. Detection of a valid receive message frame is not dependent upon storage in the receive message buffer (data frame) or transmit message buffer (remote frame). 2. Clear the VALID bit (0) before changing the initialization mode to an operation mode. 3. If only two CAN nodes are connected to the CAN bus with one transmitting a message frame in the normal mode and the other in the receive-only mode, the VALID bit is not set to 1 before the transmitting node enters the error passive state, because in receive-only mode no acknowledge is generated. 4. To clear the VALID bit, set the Clear VALID bit to 1 first and confirm that the VALID bit is cleared. If it is not cleared, perform clearing processing again. User's Manual U18743EE1V2UM00 571 Chapter 18 CAN Controller (CAN) PSMODE1 Caution PSMODE0 Power save mode 0 0 No power save mode is selected. 0 1 CAN sleep mode 1 0 Setting prohibited 1 1 CAN stop mode 1. Transition to and from the CAN stop mode must be made via CAN sleep mode. A request for direct transition to and from the CAN stop mode is ignored. 2. The MBON flag of CnGMCTRL must be checked after releasing a power save mode, prior to access the message buffers again. 3. CAN sleep mode requests are kept pending, until cancelled by software or entered on appropriate bus condition (bus idle). Software can check the actual status by reading PSMODE. OPMODE2 OPMODE1 OPMODE0 Operation mode 0 0 0 No operation mode is selected (CAN module is in the initialization mode). 0 0 1 Normal operation mode 0 1 0 Normal operation mode with automatic block transmission function (normal operation mode with ABT) 0 1 1 Receive-only mode 1 0 0 Single-shot mode 1 0 1 Self-test mode Other than above Caution Note 572 Setting prohibited Transit to initialization mode or power saving modes may take some time. Be sure to verify the success of mode change by reading the values, before proceeding. The OPMODE0 to OPMODE2 bits are read-only in the CAN sleep mode or CAN stop mode. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 (b) CnCTRL write 15 14 13 Set CCERC Set AL 0 7 6 5 0 Clear AL Clear VALID 12 11 4 3 1 CCERC bit is set to 1. 2 Clear AL 0 1 AL bit is cleared to 0. 1 0 AL bit is set to 1. AL bit is not changed. Clear VALID Setting of VALID bit 0 VALID bit is not changed. 1 VALID bit is cleared to 0. Set PSMODE0 Clear PSMODE0 0 1 PSMODE0 bit is cleared to 0. 1 0 PSMODE0 bit is set to 1. Setting of PSMODE0 bit PSMODE0 bit is not changed. Set PSMODE1 Clear PSMODE1 0 1 PSMODE1 bit is cleared to 0. 1 0 PSMODE1 bit is set to 1. Setting of PSMODE1 bit PSMODE1 bit is not changed. Set OPMODE0 Clear OPMODE0 0 1 OPMODE0 bit is cleared to 0. 1 0 OPMODE0 bit is set to 1. User's Manual U18743EE1V2UM00 0 Setting of AL bit Other than above Other than above 1 CCERC bit is not changed. Set AL Other than above 8 Clear Clear Clear Clear Clear PSMODE1 PSMODE0 OPMODE2 OPMODE1 OPMODE0 Setting of CCERC bit Other than above 9 Set Set Set Set Set PSMODE1 PSMODE0 OPMODE2 OPMODE1 OPMODE0 Set CCERC Other than above 10 Setting of OPMODE0 bit OPMODE0 bit is not changed. 573 Chapter 18 CAN Controller (CAN) Set OPMODE1 Clear OPMODE1 0 1 OPMODE1 bit is cleared to 0. 1 0 OPMODE1 bit is set to 1. Other than above OPMODE1 bit is not changed. Set OPMODE2 Clear OPMODE2 0 1 OPMODE2 bit is cleared to 0. 1 0 OPMODE2 bit is set to 1. Other than above (7) Setting of OPMODE1 bit Setting of OPMODE2 bit OPMODE2 bit is not changed. CnLEC - CANn module last error information register The CnLEC register provides the error information of the CAN protocol. Access Address Initial Value Note This register can be read/written in 8-bit units. <CnRBaseAddr> + 052H 00H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 0 0 LEC2 LEC1 LEC0 1. The contents of the CnLEC register are not cleared when the CAN module changes from an operation mode to the initialization mode. 2. If an attempt is made to write a value other than 00H to the CnLEC register by software, the access is ignored. LEC2 LEC1 LEC0 Last CAN protocol error information 574 0 0 0 No error 0 0 1 Stuff error 0 1 0 Form error 0 1 1 ACK error 1 0 0 Bit error. (The CAN module tried to transmit a recessive-level bit as part of a transmit message (except the arbitration field), but the value on the CAN bus is a dominant-level bit.) 1 0 1 Bit error. (The CAN module tried to transmit a dominant-level bit as part of a transmit message, ACK bit, error frame, or overload frame, but the value on the CAN bus is a recessive-level bit.) 1 1 0 CRC error 1 1 1 Undefined User's Manual U18743EE1V2UM00 CAN Controller (CAN) (8) Chapter 18 CnINFO - CANn module information register The CnINFO register indicates the status of the CAN module. Access Address Initial Value This register is read-only in 8-bit units. <CnRBaseAddr> + 053H 00H. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 BOFF TECS1 TECS0 RECS1 RECS0 BOFF Bus-off state bit 0 Not bus-off state (transmit error counter 255). (The value of the transmit error counter is less than 256.) 1 Bus-off state (transmit error counter > 255). (The value of the transmit error counter is 256 or more.) TECS1 TECS0 Transmission error counter status bit 0 0 The value of the transmission error counter is less than that of the warning level (< 96). 0 1 The value of the transmission error counter is in the range of the warning level (96 to 127). 1 0 Undefined 1 1 The value of the transmission error counter is in the range of the error passive or bus-off status ( 128). RECS1 RECS0 0 0 The value of the reception error counter is less than that of the warning level (< 96). 0 1 The value of the reception error counter is in the range of the warning level (96 to 127). 1 0 Undefined 1 1 The value of the reception error counter is in the error passive range ( 128). Reception error counter status bit User's Manual U18743EE1V2UM00 575 Chapter 18 CAN Controller (CAN) (9) CnERC - CANn module error counter register The CnERC register indicates the count value of the transmission/reception error counter. Access Address Initial Value This register is read-only in 16-bit units. <CnRBaseAddr> + 054H 0000H. The register is initialized by any reset. 15 14 13 12 11 10 9 8 REPS REC6 REC5 REC4 REC3 REC2 REC1 REC0 7 6 5 4 3 2 1 0 TEC7 TEC6 TEC5 TEC4 TEC3 TEC2 TEC1 TEC0 REPS 0 The reception error counter is not in the error passive range (< 128) 1 The reception error counter is in the error passive range ( 128) REC6 to REC0 0 to 127 Note 0 to 255 576 Reception error counter bit Number of reception errors. These bits reflect the status of the reception error counter. The number of errors is defined by the CAN protocol. REC6 to REC0 of the reception error counter are invalid in the reception error passive state (CnINFO.RECS[1:0] = 11B). TEC7 to TEC0 Note Reception error passive status bit Transmission error counter bit Number of transmission errors. These bits reflect the status of the transmission error counter. The number of errors is defined by the CAN protocol. The TEC7 to TEC0 bits of the transmission error counter are invalid in the bus-off state (CnINFO.BOFF = 1). User's Manual U18743EE1V2UM00 CAN Controller (CAN) (10) Chapter 18 CnIE - CANn module interrupt enable register The CnIE register is used to enable or disable the interrupts of the CAN module. Access Address Initial Value This register can be read/written in 16-bit units. <CnRBaseAddr> + 056H 0000H. The register is initialized by any reset. (a) CnIE read 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 CIE5 CIE4 CIE3 CIE2 CIE1 CIE0 CIE5 to CIE0 CAN module interrupt enable bit 0 Output of the interrupt corresponding to interrupt status register CINTSx is disabled. 1 Output of the interrupt corresponding to interrupt status register CINTSx is enabled. (b) CnIE write 15 14 13 12 11 10 9 8 0 0 Set CIE5 Set CIE4 Set CIE3 Set CIE2 Set CIE1 Set CIE0 7 6 5 4 3 2 1 0 0 0 Clear CIE5 Clear CIE4 Clear CIE3 Clear CIE2 Clear CIE1 Clear CIE0 Set CIE5 Clear CIE5 0 1 CIE5 bit is cleared to 0. 1 0 CIE5 bit is set to 1. Other than above Setting of CIE5 bit CIE5 bit is not changed. Set CIE4 Clear CIE4 0 1 CIE4 bit is cleared to 0. 1 0 CIE4 bit is set to 1. Other than above Setting of CIE4 bit CIE4 bit is not changed. Set CIE3 Clear CIE3 0 1 CIE3 bit is cleared to 0. 1 0 CIE3 bit is set to 1. Other than above User's Manual U18743EE1V2UM00 Setting of CIE3 bit CIE3 bit is not changed. 577 Chapter 18 CAN Controller (CAN) Set CIE2 Clear CIE2 0 1 CIE2 bit is cleared to 0. 1 0 CIE2 bit is set to 1. Other than above CIE2 bit is not changed. Set CIE1 Clear CIE1 0 1 CIE1 bit is cleared to 0. 1 0 CIE1 bit is set to 1. Other than above Setting of CIE1 bit CIE1 bit is not changed. Set CIE0 Clear CIE0 0 1 CIE0 bit is cleared to 0. 1 0 CIE0 bit is set to 1. Other than above 578 Setting of CIE2 bit User's Manual U18743EE1V2UM00 Setting of CIE0 bit CIE0 bit is not changed. CAN Controller (CAN) (11) Chapter 18 CnINTS - CANn module interrupt status register The CnINTS register indicates the interrupt status of the CAN module. Access Address Initial Value This register can be read/written in 16-bit units. <CnRBaseAddr> + 058H 0000H. The register is initialized by any reset. (a) CnINTS read 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 CINTS5 CINTS4 CINTS3 CINTS2 CINTS1 CINTS0 CINTS5 to CINTS0 0 No related interrupt source event is pending. 1 A related interrupt source event is pending. Interrupt status bit a) CAN interrupt status bit Related interrupt source event CINTS5 Wakeup interrupt from CAN sleep modea CINTS4 Arbitration loss interrupt CINTS3 CAN protocol error interrupt CINTS2 CAN error status interrupt CINTS1 Interrupt on completion of reception of valid message frame to message buffer m CINTS0 Interrupt on normal completion of transmission of message frame from message buffer m The CINTS5 bit is set only when the CAN module is woken up from the CAN sleep mode by a CAN bus operation. The CINTS5 bit is not set when the CAN sleep mode has been released by software. (b) CnINTS write 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 Clear CINTS5 Clear CINTS4 Clear CINTS3 Clear CINTS2 Clear CINTS1 Clear CINTS0 Clear CINTS5 to CINTS0 Caution Setting of CINTS5 to CINTS0 bits 0 CINTS5 to CINTS0 bits are not changed. 1 CINTS5 to CINTS0 bits are cleared to 0. Please clear the status bit of this register with software when the confirmation of each status is necessary in the interrupt processing, because these bits are not cleared automatically. User's Manual U18743EE1V2UM00 579 Chapter 18 CAN Controller (CAN) (12) CnBRP - CANn module bit rate prescaler register The CnBRP register is used to select the CAN protocol layer basic system clock (fTQ). The communication baud rate is set to the CnBTR register. Access Address Initial Value This register can be read/written in 8-bit units. <CnRBaseAddr> + 05AH FFH. The register is initialized by any reset. 7 6 5 4 3 2 1 0 TQPRS7 TQPRS6 TQPRS5 TQPRS4 TQPRS3 TQPRS2 TQPRS1 TQPRS0 TQPRS7 to TQPRS0 CAN protocol layer base system clock (fTQ) 0 fCANMOD/1 1 fCANMOD/2 n fCANMOD/(n+1) : : 255 fCANMOD/256 (default value) CANn module clock selection register (CnGMCS) 0 0 fCAN 0 0 CCP3 CCP2 CCP1 CCP0 fCANMOD Baud rate generator Prescaler fTQ CANn bit-rate register (CnBTR) TQPRS7 TQPRS6 TQPRS5 TQPRS4 TQPRS3 TQPRS2 TQPRS1 TQPRS0 CANn module bit-rate prescaler register (CnBRP) Figure 18-24 Note Caution 580 CAN module clock fCAN: clock supplied to CAN fCANMOD: CAN module system clock fTQ: CAN protocol layer basic system clock The CnBRP register can be write-accessed only in the initialization mode. User's Manual U18743EE1V2UM00 CAN Controller (CAN) (13) Chapter 18 CnBTR - CANn module bit rate register The CnBTR register is used to control the data bit time of the communication baud rate. Access Address Initial Value This register can be read/written in 16-bit units. <CnRBaseAddr> + 05CH 370FH. The register is initialized by any reset. 15 14 13 12 11 0 0 SJW1 SJW0 0 7 6 5 4 0 0 0 0 10 9 8 TSEG22 TSEG21 TSEG20 3 2 1 0 TSEG13 TSEG12 TSEG11 TSEG10 Data bit time (DBT) Sync segment Prop segment Phase segment 1 Time segment 1 (TSEG1) Figure 18-25 Phase segment 2 Time segment 2 (TSEG2) Sample point (SPT) Data bit time SJW1 SJW0 Length of synchronization jump width 0 0 1TQ 0 1 2TQ 1 0 3TQ 1 1 4TQ (default value) TSEG22 TSEG21 TSEG20 Length of time segment 2 0 0 0 1TQ 0 0 1 2TQ 0 1 0 3TQ 0 1 1 4TQ 1 0 0 5TQ 1 0 1 6TQ 1 1 0 7TQ 1 1 1 8TQ (default value) User's Manual U18743EE1V2UM00 581 Chapter 18 CAN Controller (CAN) TSEG13 TSEG12 TSEG11 TSEG10 Length of time segment 1 a) Note (14) 0 0 0 0 Setting prohibited 0 0 0 1 2TQa 0 0 1 0 3TQa 0 0 1 1 4TQ 0 1 0 0 5TQ 0 1 0 1 6TQ 0 1 1 0 7TQ 0 1 1 1 8TQ 1 0 0 0 9TQ 1 0 0 1 10TQ 1 0 1 0 11TQ 1 0 1 1 12TQ 1 1 0 0 13TQ 1 1 0 1 14TQ 1 1 1 0 15TQ 1 1 1 1 16TQ (default value) This setting must not be made when the CnBRP register = 00H TQ = 1/fTQ (fTQ: CAN protocol layer basic system clock) CnLIPT - CANn module last in-pointer register The CnLIPT register indicates the number of the message buffer in which a data frame or a remote frame was last stored. Access Address Initial Value This register is read-only in 8-bit units. <CnRBaseAddr> + 05EH Undefined. 7 6 5 4 3 2 1 0 LIPT7 LIPT6 LIPT5 LIPT4 LIPT3 LIPT2 LIPT1 LIPT0 LIPT7 to LIPT0 0 to 31 Note 582 Last in-pointer register (CnLIPT) When the CnLIPT register is read, the contents of the element indexed by the last in-pointer (LIPT) of the receive history list are read. These contents indicate the number of the message buffer in which a data frame or a remote frame was last stored. The read value of the CnLIPT register is undefined if a data frame or a remote frame has never been stored in the message buffer. If the RHPM bit of the CnRGPT register is set to 1 after the CAN module has changed from the initialization mode to an operation mode, therefore, the read value of the CnLIPT register is undefined. User's Manual U18743EE1V2UM00 CAN Controller (CAN) (15) Chapter 18 CnRGPT - CANn module receive history list register The CnRGPT register is used to read the receive history list. Access Address Initial Value This register can be read/written in 16-bit units. <CnRBaseAddr> + 060H xx02H. The register is initialized by any reset. (a) CnRGPT read a) 15 14 13 12 11 10 9 8 RGPT7 RGPT6 RGPT5 RGPT4 RGPT3 RGPT2 RGPT1 RGPT0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 RHPM ROVF RGPT7 to RGPT0 Receive history list read pointer 0 to 31 When the CnRGPT register is read, the contents of the element indexed by the receive history list get pointer (RGPT) of the receive history list are read. These contents indicate the number of the message buffer in which a data frame or a remote frame has been stored. RHPMa Receive history list pointer match 0 The receive history list has at least one message buffer number that has not been read. 1 The receive history list has no message buffer numbers that have not been read. The read value of the RGPT0 to RGPT7 bits is invalid when the RHPM bit = 1. ROVFa a) Receive history list overflow bit 0 All the message buffer numbers that have not been read are preserved. All the numbers of the message buffers in which a new data frame or remote frame has been received and stored are recorded to the receive history list (the receive history list has a vacant element). 1 At least 23 entries have been stored since the host processor has serviced the RHL last time (i.e. read CnRGPT). The first 22 entries are sequentially stored while the last entry can have been overwritten whenever newly received message is stored because all buffer numbers are stored at position LIPT-1 when ROVF bit is set. Thus the sequence of receptions can not be recovered completely now. If ROVF is set, RHPM is no longer cleared on message storage, but RHPM is still set, if all entries of CnRGPT are read by software. User's Manual U18743EE1V2UM00 583 Chapter 18 CAN Controller (CAN) (b) CnRGPT write 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 Clear ROVF Clear ROVF (16) Setting of ROVF bit 0 ROVF bit is not changed. 1 ROVF bit is cleared to 0. CnLOPT - CANn module last out-pointer register The CnLOPT register indicates the number of the message buffer to which a data frame or a remote frame was transmitted last. Access Address Initial Value This register is read-only in 8-bit units. <CnRBaseAddr> + 062H Undefined 7 6 5 4 3 2 1 0 LOPT7 LOPT6 LOPT5 LOPT4 LOPT3 LOPT2 LOPT1 LOPT0 LOPT7 to LOPT0 0 to 31 Note 584 Last out-pointer of transmit history list (LOPT) When the CnLOPT register is read, the contents of the element indexed by the last out-pointer (LOPT) of the receive history list are read. These contents indicate the number of the message buffer to which a data frame or a remote frame was transmitted last. The value read from the CnLOPT register is undefined if a data frame or remote frame has never been transmitted from a message buffer. If the CnTGPT.THPM bit is set to 1 after the CAN module has changed from the initialization mode to an operation mode, therefore, the read value of the CnLOPT register is undefined. User's Manual U18743EE1V2UM00 CAN Controller (CAN) (17) Chapter 18 CnTGPT - CANn module transmit history list register The CnTGPT register is used to read the transmit history list. Access Address Initial Value This register can be read/written in 16-bit units. <CnRBaseAddr> + 064H xx02H. The register is initialized by any reset. (a) CnTGPT read 15 14 13 12 11 10 9 8 TGPT7 TGPT6 TGPT5 TGPT4 TGPT3 TGPT2 TGPT1 TGPT0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 THPM TOVF TGPT7 to TGPT0 a) 0 to 31 When the CnTGPT register is read, the contents of the element indexed by the read pointer (TGPT) of the transmit history list are read. These contents indicate the number of the message buffer to which a data frame or a remote frame was transmitted last. THPMa Transmit history pointer match 0 The transmit history list has at least one message buffer number that has not been read. 1 The transmit history list has no message buffer numbers that have not been read. The read value of the TGPT0 to TGPT7 bits is invalid when the THPM bit = 1. TOVFa a) Note Transmit history list read pointer Transmit history list overflow bit 0 All the message buffer numbers that have not been read are preserved. All the numbers of the message buffers to which a new data frame or remote frame has been transmitted are recorded to the transmit history list (the transmit history list has a vacant element). 1 At least 7 entries have been stored since the host processor has serviced the THL last time (i.e. read CnTGPT). The first 6 entries are sequentially stored while the last entry can have been overwritten whenever a message is newly transmitted because all buffer numbers are stored at position LOPT-1 when TOVF bit is set. Thus the sequence of transmissions can not be recovered completely now. If TOVF is set, THPM is no longer cleared on message transmission, but THPM is still set, if all entries of CnTGPT are read by software. Transmission from message buffers 0 to 7 is not recorded to the transmit history list in the normal operation mode with ABT. User's Manual U18743EE1V2UM00 585 Chapter 18 CAN Controller (CAN) (b) CnTGPT write 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 Clear TOVF Clear TOVF 586 Setting of TOVF bit 0 TOVF bit is not changed. 1 TOVF bit is cleared to 0. User's Manual U18743EE1V2UM00 CAN Controller (CAN) (18) Chapter 18 CnTS - CANn module time stamp register The CnTS register is used to control the time stamp function. Access Address Initial Value This register can be read/written in 16-bit units. <CnRBaseAddr> + 066H 0000H. The register is initialized by any reset. (a) CnTS read Note 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 TSLOCK TSSEL TSEN The lock function of the time stamp function must not be used when the CAN module is in the normal operation mode with ABT. TSLOCK a) 0 Time stamp lock function stopped. The TSOUT signal is toggled each time the selected time stamp capture event occurs. 1 Time stamp lock function enabled. The TSOUT signal is toggled each time the selected time stamp capture event occurs. However, the TSOUT output signal is locked when a data frame has been correctly received to message buffer 0a. The TSEN bit is automatically cleared to 0. TSSEL Time stamp capture event selection bit 0 The time capture event is SOF. 1 The time stamp capture event is the last bit of EOF. TSEN Remark Time stamp lock function enable bit TSOUT operation setting bit 0 TSOUT toggle operation is disabled. 1 TSOUT toggle operation is enabled. The TSOUT signal is output from the CAN controller to the timer. For details, refer to Chapter 10 on page 305." User's Manual U18743EE1V2UM00 587 Chapter 18 CAN Controller (CAN) (b) CnTS write 15 14 13 12 11 10 9 8 0 0 0 0 0 Set TSLOCK Set TSSEL Set TSEN 7 6 5 4 3 2 1 0 0 0 0 0 0 Clear TSLOCK Clear TSSEL Clear TSEN Set TSLOCK Clear TSLOCK 0 1 TSLOCK bit is cleared to 0. 1 0 TSLOCK bit is set to 1. Other than above TSLOCK bit is not changed. Set TSSEL Clear TSSEL 0 1 TSSEL bit is cleared to 0. 1 0 TSSEL bit is set to 1. Setting of TSSEL bit Other than above TSSEL bit is not changed. Set TSEN Clear TSEN Setting of TSEN bit 0 1 TSEN bit is cleared to 0. 1 0 TSEN bit is set to 1. Other than above 588 Setting of TSLOCK bit TSEN bit is not changed. User's Manual U18743EE1V2UM00 CAN Controller (CAN) (19) Chapter 18 CnMDATAxm, CnMDATAzm - CANn message data byte register (x = 0 to 7, z = 01, 23, 45, 67) The CnMDATAxm, CnMDATAzm registers are used to store the data of a transmit/receive message. Access Address Initial Value The CnMDATAzm registers can be read/written in 16-bit units. The CnMDATAxm registers can be read/written in 8-bit units. Refer to "CAN registers overview" on page 555. Undefined. CnMDATA01m 15 14 13 12 11 10 MDATA0115 MDATA0114 MDATA0113 MDATA0112 MDATA0111 MDATA0110 9 8 MDATA019 MDATA018 7 6 5 4 3 2 1 0 MDATA017 MDATA016 MDATA015 MDATA014 MDATA013 MDATA012 MDATA011 MDATA010 7 6 5 4 3 2 1 0 MDATA07 MDATA06 MDATA05 MDATA04 MDATA03 MDATA02 MDATA01 MDATA00 7 6 5 4 3 2 1 0 MDATA17 MDATA16 MDATA15 MDATA14 MDATA13 MDATA12 MDATA11 MDATA1 14 13 12 11 10 9 8 MDATA239 MDATA238 CnMDATA0m CnMDATA1m CnMDATA23m 15 MDATA2315 MDATA2314 MDATA2313 MDATA2312 MDATA2311 MDATA2310 7 6 5 4 3 2 1 0 MDATA237 MDATA236 MDATA235 MDATA234 MDATA233 MDATA232 MDATA231 MDATA230 7 6 5 4 3 2 1 0 MDATA27 MDATA26 MDATA25 MDATA24 MDATA23 MDATA22 MDATA21 MDATA20 7 6 5 4 3 2 1 0 MDATA37 MDATA36 MDATA35 MDATA34 MDATA33 MDATA32 MDATA31 MDATA30 CnMDATA2m CnMDATA3m User's Manual U18743EE1V2UM00 589 Chapter 18 CAN Controller (CAN) CnMDATA45m 15 14 13 12 11 10 MDATA4515 MDATA4514 MDATA4513 MDATA4512 MDATA4511 MDATA4510 9 8 MDATA459 MDATA458 7 6 5 4 3 2 1 0 MDATA457 MDATA456 MDATA455 MDATA454 MDATA453 MDATA452 MDATA451 MDATA450 7 6 5 4 3 2 1 0 MDATA47 MDATA46 MDATA45 MDATA44 MDATA43 MDATA42 MDATA41 MDATA40 7 6 5 4 3 2 1 0 MDATA57 MDATA56 MDATA55 MDATA54 MDATA53 MDATA52 MDATA51 MDATA50 14 13 12 11 10 9 8 MDATA679 MDATA678 CnMDATA4m CnMDATA5m CnMDATA67m 15 MDATA6715 MDATA6714 MDATA6713 MDATA6712 MDATA6711 MDATA6710 7 6 5 4 3 2 1 0 MDATA677 MDATA676 MDATA675 MDATA674 MDATA673 MDATA672 MDATA671 MDATA670 7 6 5 4 3 2 1 0 MDATA67 MDATA66 MDATA65 MDATA64 MDATA63 MDATA62 MDATA61 MDATA60 7 6 5 4 3 2 1 0 MDATA77 MDATA76 MDATA75 MDATA74 MDATA73 MDATA72 MDATA71 MDATA70 CnMDATA6m CnMDATA7m 590 User's Manual U18743EE1V2UM00 CAN Controller (CAN) (20) Chapter 18 CnMDLCm - CANn message data length register m The CnMDLCm register is used to set the number of bytes of the data field of a message buffer. Access Address Initial Value This register can be read/written in 8-bit units. Refer to "CAN registers overview" on page 555. 0000xxxxB. The register is initialized by any reset. 7 6 5 4 3 2 1 0 0 0 0 0 MDLC3 MDLC2 MDLC1 MDLC0 MDLC3 MDLC2 MDLC1 MDLC0 Data length of transmit/receive message Note 0 0 0 0 0 bytes 0 0 0 1 1 byte 0 0 1 0 2 bytes 0 0 1 1 3 bytes 0 1 0 0 4 bytes 0 1 0 1 5 bytes 0 1 1 0 6 bytes 0 1 1 1 7 bytes 1 0 0 0 8 bytes 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 Setting prohibited (If these bits are set during transmission, 8-byte data is transmitted regardless of the set DLC value when a data frame is transmitted. However, the DLC actually transmitted to the CAN bus is the DLC value set to this register.)Note 1 1 1 0 1 1 1 1 The data and DLC value actually transmitted to CAN bus are as follows. Type of transmit frame Caution Length of transmit data DLC transmitted Data frame Number of bytes specified by DLC (However, 8 bytes if DLC 8) MDLC3 to MDLC0 bits Remote frame 0 bytes 1. Be sure to set bits 7 to 4 to 0000B. 2. Receive data is stored in as many CnMDATAxm register as the number of bytes (however, the upper limit is 8) corresponding to DLC of the received frame. The CnMDATAxm register in which no data is stored is undefined. User's Manual U18743EE1V2UM00 591 Chapter 18 CAN Controller (CAN) (21) CnMCONFm - CANn message configuration register m The CnMCONFm register is used to specify the type of the message buffer and to set a mask. Access Address Initial Value This register can be read/written in 8-bit units. Refer to "CAN registers overview" on page 555. Undefined. 7 6 5 4 3 2 1 0 OWS RTR MT2 MT1 MT0 0 0 MA0 OWS a) Note Overwrite control bit 0 The message buffer that has already received a data framea is not overwritten by a newly received data frame. The newly received data frame is discarded. 1 The message buffer that has already received a data framea is overwritten by a newly received data frame. The "message buffer that has already received a data frame" is a receive message buffer whose the CnMCTRLm.DN bit has been set to 1. A remote frame is received and stored, regardless of the setting of OWS and DN. A remote frame that satisfies the other conditions (ID matches, RTR = 0, TRQ = 0) is always received and stored in the corresponding message buffer (interrupt generated, DN flag set, MDLC[3:0] updated, and recorded to the receive history list). RTR a) Remote frame request bita 0 Transmit a data frame. 1 Transmit a remote frame. The RTR bit specifies the type of message frame that is transmitted from a message buffer defined as a transmit message buffer. Even if a valid remote frame has been received, the RTR bit of the transmit message buffer that has received the frame remains cleared to 0. Even if a remote frame whose ID matches has been received from the CAN bus with the RTR bit of the transmit message buffer set to 1 to transmit a remote frame, that remote frame is not received or stored (interrupt generated, DN flag set, the MDLC0 to MDLC3 bits updated, and recorded to the receive history list). MT2 MT1 MT0 0 0 0 Transmit message buffer 0 0 1 Receive message buffer (no mask setting) 0 1 0 Receive message buffer (mask 1 set) 0 1 1 Receive message buffer (mask 2 set) 1 0 0 Receive message buffer (mask 3 set) 1 0 1 Receive message buffer (mask 4 set) Other than above 592 User's Manual U18743EE1V2UM00 Message buffer type setting bit Setting prohibited CAN Controller (CAN) Chapter 18 MA0 Caution Message buffer assignment bit 0 Message buffer not used. 1 Message buffer used. Be sure to write 0 to bits 2 and 1. User's Manual U18743EE1V2UM00 593 Chapter 18 CAN Controller (CAN) (22) CnMIDLm, CnMIDHm - CANn message ID register m The CnMIDLm and CnMIDHm registers are used to set an identifier (ID). Access Address Initial Value These registers can be read/written in 16-bit units. Refer to "CAN registers overview" on page 555. Undefined. CnMIDLm 15 14 13 12 11 10 9 8 ID15 ID14 ID13 ID12 ID11 ID10 ID9 ID8 7 6 5 4 3 2 1 0 ID7 ID6 ID5 ID4 ID3 ID2 ID1 ID0 15 14 13 12 11 10 9 8 IDE 0 0 ID28 ID27 ID26 ID25 ID24 7 6 5 4 3 2 1 0 ID23 ID22 ID21 ID20 ID19 ID18 ID17 ID16 CnMIDHm IDE a) Caution Format mode specification bit 0 Standard format mode (ID28 to ID18: 11 bits)a 1 Extended format mode (ID28 to ID0: 29 bits) The ID17 to ID0 bits are not used. ID28 to ID0 Message ID ID28 to ID18 Standard ID value of 11 bits (when IDE = 0) ID28 to ID0 Extended ID value of 29 bits (when IDE = 1) 1. Be sure to write 0 to bits 14 and 13 of the CnMIDHm register. 2. Be sure to align the ID value according to the given bit positions into this registers. Note that for standard ID, the ID value must be shifted to fit into ID28 to ID18 bit positions. 594 User's Manual U18743EE1V2UM00 CAN Controller (CAN) (23) Chapter 18 CnMCTRLm - CANn message control register m The CnMCTRLm register is used to control the operation of the message buffer. Access This register can be read/written in 16-bit units. Address Refer to "CAN registers overview" on page 555. Initial Value 00x0 0000 0000 0000B. The register is initialized by any reset. (a) CnMCTRLm read 15 14 13 12 11 10 9 8 0 0 MUC 0 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 MOW IE DN TRQ RDY MUCa a) 0 The CAN module is not updating the message buffer (reception and storage). 1 The CAN module is updating the message buffer (reception and storage). The MUC bit is undefined until the first reception and storage is performed. MOWa a) Bit indicating that message buffer data is being updated Message buffer overwrite status bit 0 The message buffer is not overwritten by a newly received data frame. 1 The message buffer is overwritten by a newly received data frame. The MOW bit is not set to 1 even if a remote frame is received and stored in the transmit message buffer with the DN bit = 1. IE Message buffer interrupt request enable bit 0 Receive message buffer: Valid message reception completion interrupt disabled. Transmit message buffer: Normal message transmission completion interrupt disabled. 1 Receive message buffer: Valid message reception completion interrupt enabled. Transmit message buffer: Normal message transmission completion interrupt enabled. DN Message buffer data update bit 0 A data frame or remote frame is not stored in the message buffer. 1 A data frame or remote frame is stored in the message buffer. User's Manual U18743EE1V2UM00 595 Chapter 18 CAN Controller (CAN) TRQ Message buffer transmission request bit 0 No message frame transmitting request that is pending or being transmitted is in the message buffer. 1 The message buffer is holding transmission of a message frame pending or is transmitting a message frame. RDY Message buffer ready bit 0 The message buffer can be written by software. The CAN module cannot write to the message buffer. 1 Writing the message buffer by software is ignored (except a write access to the RDY, TRQ, DN, and MOW bits). The CAN module can write to the message buffer. (b) CnMCTRLm write 15 14 13 12 11 10 9 8 0 0 0 0 Set IE 0 Set TRQ Set RDY 7 6 5 4 3 2 1 0 0 0 0 Clear MOW Clear IE Clear DN Clear TRQ Clear RDY Clear MOW Setting of MOW bit 0 MOW bit is not changed. 1 MOW bit is cleared to 0. Set IE Clear IE 0 1 IE bit is cleared to 0. 1 0 IE bit is set to 1. Other than above Clear DN IE bit is not changed. Setting of DN bit 1 DN bit is cleared to 0. 0 DN bit is not changed. Set TRQ Clear TRQ 0 1 TRQ bit is cleared to 0. 1 0 TRQ bit is set to 1. Other than above 596 Setting of IE bit Setting of TRQ bit TRQ bit is not changed. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 Set RDY Clear RDY 0 1 RDY bit is cleared to 0. 1 0 RDY bit is set to 1. Other than above Caution Setting of RDY bit RDY bit is not changed. 1. Set IE bit and RDY bit always separately. 2. Do not set the DN bit to 1 by software. Be sure to write 0 to bit 10. 3. Do not set the TRQ bit and the RDY bit (1) at the same time. Set the RDY bit (1) before setting the TRQ bit. 4. Do not clear the RDY bit (0) during message transmission. Follow the transmission abort process about clearing the RDY bit (0) for redefinition of the message buffer. 5. Clear again when RDY bit is not cleared even if this bit is cleared. 6. Be sure that RDY is cleared before writing to the other message buffer registers, by checking the status of the RDY bit. User's Manual U18743EE1V2UM00 597 Chapter 18 CAN Controller (CAN) 18.8 CAN Controller Initialization 18.8.1 Initialization of CAN module Before CAN module operation is enabled, the CAN module system clock needs to be determined by setting the CCP[3:0] bits of the CnGMCS register by software. Do not change the setting of the CAN module system clock after CAN module operation is enabled. The CAN module is enabled by setting the GOM bit of the CnGMCTRL register. For the procedure of initializing the CAN module, refer to "Operation of CAN Controller" on page 637. 18.8.2 Initialization of message buffer After the CAN module is enabled, the message buffers contain undefined values. A minimum initialization for all the message buffers, even for those not used in the application, is necessary before switching the CAN module from the initialization mode to one of the operation modes. * Clear the RDY, TRQ, and DN bits of all CnMCTRLm registers to 0. * Clear the MA0 bit of all CnMCONFm registers to 0. 18.8.3 Redefinition of message buffer Redefining a message buffer means changing the ID and control information of the message buffer while a message is being received or transmitted, without affecting other transmission/reception operations. (1) To redefine message buffer in initialization mode Place the CAN module in the initialization mode once and then change the ID and control information of the message buffer in the initialization mode. After changing the ID and control information, set the CAN module to an operation mode. (2) To redefine message buffer during reception Perform redefinition as shown in Figure 18-38. (3) To redefine message buffer during transmission To rewrite the contents of a transmit message buffer to which a transmission request has been set, perform transmission abort processing (see "Transmission abort process except for in normal operation mode with automatic block transmission (ABT)" on page 616 and "Transmission abort process except for ABT transmission in normal operation mode with automatic block transmission (ABT)" on page 616). Confirm that transmission has been aborted or completed, and then redefine the message buffer. After redefining 598 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 the transmit message buffer, set a transmission request using the procedure described below. When setting a transmission request to a message buffer that has been redefined without aborting the transmission in progress, however, the 1-bit wait time is not necessary. Redefinition completed Execute transmission? No Yes Wait for 1 bit of CAN data. Set TRQ bit Set TRQ bit = 1 Clear TRQ bit = 0 END Figure 18-26 Caution Setting transmission request (TRQ) to transmit message buffer after redefinition 1. When a message is received, reception filtering is performed in accordance with the ID and mask set to each receive message buffer. If the procedure in Figure 18-38 on page 640 is not observed, the contents of the message buffer after it has been redefined may contradict the result of reception (result of reception filtering). If this happens, check that the ID and IDE received first and stored in the message buffer following redefinition are those stored after the message buffer has been redefined. If no ID and IDE are stored after redefinition, redefine the message buffer again. 2. When a message is transmitted, the transmission priority is checked in accordance with the ID, IDE, and RTR bits set to each transmit message buffer to which a transmission request was set. The transmit message buffer having the highest priority is selected for transmission. If the procedure in Figure 18-26 on page 599 is not observed, a message with an ID not having the highest priority may be transmitted after redefinition. User's Manual U18743EE1V2UM00 599 Chapter 18 CAN Controller (CAN) 18.8.4 Transition from initialization mode to operation mode The CAN module can be switched to the following operation modes. * Normal operation mode * Normal operation mode with ABT * Receive-only mode * Single-shot mode * Self-test mode OPMODE[2:0] = 00H and CAN bus is busy. [Receive-only mode] OPMODE[2:0]=03H OPMODE[2:0] = 00H and CAN bus is busy. OPMODE[2:0] = 00H and CAN bus is busy. [Normal operation mode with ABT] OPMODE[2:0]=02H OPMODE[2:0] = 03H OPMODE[2:0] = 00H and interframe space OPMODE[2:0] = 00H and interframe space OPMODE[2:0] = 04H OPMODE[2:0] = 02H OPMODE[2:0] = 00H and CAN bus is busy. [Normal operation mode] OPMODE[2:0]=01H OPMODE[2:0] = 00H and interframe space OPMODE[2:0] = 01H [Single-shot mode] OPMODE[2:0]=04H OPMODE[2:0] = 00H and interframe space INIT mode OPMODE[2:0] = 00H OPMODE[2:0] = 05H OPMODE[2:0] = 00H and interframe space OPMODE[2:0] = 00H and CAN bus is busy. [Self-test mode] OPMODE[2:0]=05H GOM = 1 All CAN modules are in INIT mode and GOM = 0 EFSD = 1 and GOM = 0 CAN module channel invalid RESET released RESET Figure 18-27 Transition to operation modes The transition from the initialization mode to an operation mode is controlled by the bit string OPMODE[2:0] in the CnCTRL register. Changing from one operation mode into another requires shifting to the initialization mode in between. Do not change one operation mode to another directly; otherwise the operation will not be guaranteed. Requests for transition from an operation mode to the initialization mode are held pending when the CAN bus is not in the interframe space (i.e., frame reception or transmission is in progress), and the CAN module enters the initialization mode at the first bit in the interframe space (the values of the OPMODE[2:0] bits are changed to 000B). After issuing a request to change the mode to the initialization mode, read the OPMODE[2:0] bits until their value becomes 000B to confirm that the module has entered the initialization mode (see Figure 18-36 on page 638). 600 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.8.5 Resetting error counter CnERC of CAN module If it is necessary to reset the CAN module error counter CnERC and CAN module information register CnINFO when re-initialization or forced recovery from the bus-off status is made, set the CCERC bit of the CnCTRL register to 1 in the initialization mode. When this bit is set to 1, the CnERC and CnINFO registers are cleared to their default values. User's Manual U18743EE1V2UM00 601 Chapter 18 CAN Controller (CAN) 18.9 Message Reception 18.9.1 Message reception In all the operation modes, the complete message buffer area is analyzed to find a suitable buffer to store a newly received message. All message buffers satisfying the following conditions are included in that evaluation (RX-search process). * Used as a message buffer (MA0 bit of CnMCONFm register set to 1.) * Set as a receive message buffer (MT[2:0] bits of CnMCONFm register are set to 001B, 010B, 011B, 100B, or 101B.) * Ready for reception (RDY bit of CnMCTRLm register is set to 1.) When two or more message buffers of the CAN module receive a message, the message is stored according to the priority explained below. The message is always stored in the message buffer with the highest priority, not in a message buffer with a low priority. For example, when an unmasked receive message buffer and a receive message buffer linked to mask 1 have the same ID, the received message is not stored in the message buffer linked to mask 1, even if that message buffer has not received a message and a message has already been received in the unmasked receive message buffer. In other words, when a condition has been set in two or more message buffers with different priorities, the message buffer with the highest priority always stores the message; the message is not stored in message buffers with a lower priority. This also applies when the message buffer with the highest priority is unable to store a message (i.e., when DN = 1 indicating that a message has already been received, but rewriting is disabled because OWS = 0). In this case, the message is not actually stored in the candidate message buffer with the highest priority, but neither is it stored in a message buffer with a lower priority. Table 18-24 MBRB priorities Priority Storing condition if same ID is set 1 (high) Unmasked message buffer DN bit = 0 DN bit = 1 and OWS bit = 1 2 Message buffer linked to mask 1 DN bit = 0 DN bit = 1 and OWS bit = 1 3 Message buffer linked to mask 2 DN bit = 0 DN bit = 1 and OWS bit = 1 4 Message buffer linked to mask 3 DN bit = 0 DN bit = 1 and OWS bit = 1 5 (low) Message buffer linked to mask 4 DN bit = 0 DN bit = 1 and OWS bit = 1 602 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.9.2 Receive data read To keep data consistency when reading CAN message buffers, perform the data reading according to Figure 18-49 on page 651 to Figure 18-51 on page 653. During message reception, the CAN module sets DN of the CnMCTRLm register two times: at the beginning of the storage process of data to the message buffer, and again at the end of this storage process. During this storage process, the MUC bit of the CnMCTRLm register of the message buffer is set. (Refer to Figure 18-28 on page 603.) The receive history list is also updated just before the storgage process. In addition, during storage process (MUC = 1), the RDY bit of the CnMCTRL register of the message buffer is locked to avoid the coincidental data WR by CPU. Note the storage process may be disturbed (delayed) when the CPU accesses the message buffer. (11) R0 (1) IDE ID RTR SOF CAN std ID format (1) (1) (1) Recessive DLC DATA0-DATA7 CRC (4) (0-64) (16) ACK EOF (2) IFS Dominant (7) Message Store MDATA,MDLC.MIDx- > MBUF DN MUC CINTS1 INTREC1 Operation of the CAN contoroller Figure 18-28 Set DN & MUC at the same time Set DN & clear MUC at the same timing DN and MUC bit setting period (for standard ID format) User's Manual U18743EE1V2UM00 603 Chapter 18 CAN Controller (CAN) 18.9.3 Receive history list function The receive history list (RHL) function records in the receive history list the number of the receive message buffer in which each data frame or remote frame was received and stored. The RHL consists of storage elements equivalent to up to 23 messages, the last in-message pointer (LIPT) with the corresponding CnLIPT register and the receive history list get pointer (RGPT) with the corresponding CnRGPT register. The RHL is undefined immediately after the transition of the CAN module from the initialization mode to one of the operation modes. The CnLIPT register holds the contents of the RHL element indicated by the value of the LIPT pointer minus 1. By reading the CnLIPT register, therefore, the number of the message buffer that received and stored a data frame or remote frame first can be checked. The LIPT pointer is utilized as a write pointer that indicates to what part of the RHL a message buffer number is recorded. Any time a data frame or remote frame is received and stored, the corresponding message buffer number is recorded to the RHL element indicated by the LIPT pointer. Each time recording to the RHL has been completed, the LIPT pointer is automatically incremented. In this way, the number of the message buffer that has received and stored a frame will be recorded chronologically. The RGPT pointer is utilized as a read pointer that reads a recorded message buffer number from the RHL. This pointer indicates the first RHL element that the CPU has not read yet. By reading the CnRGPT register by software, the number of a message buffer that has received and stored a data frame or remote frame can be read. Each time a message buffer number is read from the CnRGPT register, the RGPT pointer is automatically incremented. If the value of the RGPT pointer matches the value of the LIPT pointer, the RHPM bit (receive history list pointer match) of the CnRGPT register is set to 1. This indicates that no message buffer number that has not been read remains in the RHL. If a new message buffer number is recorded, the LIPT pointer is incremented and because its value no longer matches the value of the RGPT pointer, the RHPM bit is cleared. In other words, the numbers of the unread message buffers exist in the RHL. If the LIPT pointer is incremented and matches the value of the RGPT pointer minus 1, the ROVF bit (receive history list overflow) of the CnRGPT register is set to 1. This indicates that the RHL is full of numbers of message buffers that have not been read. When further message reception and storing occur, the last recorded message buffer number is overwritten by the number of the message buffer that received and stored the newly received message. In this case, after the ROVF bit has been set (1), the recorded message buffer numbers in the RHL do not completely reflect the chronological order. However messages itself are not lost and can be located by CPU search in message buffer memory with the help of the DN-bit. Caution 604 If the history list is in the overflow condition (ROVF is set), reading the history list contents is still possible, until the history list is empty (indicated by RHPM flag set). Nevertheless, the history list remains in the overflow condition, until ROVF is cleared by software. If ROVF is not cleared, the RHPM flag will also not be updated (cleared) upon a message storage of newly received frame. This may lead to the situation, that RHPM indicates an empty history list, although a reception has taken place, while the history list is in the overflow state (ROVF and RHPM are set). User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 As long as the RHL contains 23 or less entries the sequence of occurrence is maintained. If more receptions occur without reading the RHL by the host processor, complete sequence of receptions can not be recovered. Figure 18-29 Receive history list User's Manual U18743EE1V2UM00 605 Chapter 18 CAN Controller (CAN) 18.9.4 Mask function For any message buffer, which is used for reception, the assignment to one of four global reception masks (or no mask) can be selected. By using the mask function, the message ID comparison can be reduced by masked bits, herewith allowing the reception of several different IDs into one buffer. While the mask function is in effect, an identifier bit that is defined to be 1 by a mask in the received message is not compared with the corresponding identifier bit in the message buffer. However, this comparison is performed for any bit whose value is defined as 0 by the mask. For example, let us assume that all messages that have a standard-format ID, in which bits ID27 to ID25 are 0 and bits ID24 and ID22 are 1, are to be stored in message buffer 14. The procedure for this example is shown below. 1. Identifier to be stored in message buffer ID28 ID27 ID26 ID25 ID24 ID23 ID22 ID21 ID20 ID19 ID18 x 0 0 0 1 x 1 x x x x 2. Identifier to be configured in message buffer 14 (example) (Using CnMIDL14 and CnMIDH14 registers) Note ID28 ID27 ID26 ID25 ID24 ID23 ID22 ID21 ID20 ID19 ID18 x 0 0 0 1 x 1 x x x x ID17 ID16 ID15 ID14 ID13 ID12 ID11 ID10 ID9 ID8 ID7 x x x x x x x x x x x ID6 ID5 ID4 ID3 ID2 ID1 ID0 x x x x x x x 1. ID with the ID27 to ID25 bits cleared to 0 and the ID24 and ID22 bits set to 1 is registered (initialized) to message buffer 14. 2. Message buffer 14 is set as a standard format identifier that is linked to mask 1 (MT[2:0] of CnMCONF14 register are set to 010B). Mask setting for CAN module 0(mask 1) (example) (Using CAN0 address mask 1 registers L and H (C0MASKL1 and C0MASKH1)) CMID28 CMID27 CMID26 CMID25 CMID24 CMID23 CMID22 CMID21 CMID20 CMID19 CMID18 1 0 0 0 0 1 0 1 1 1 1 CMID17 CMID16 CMID15 CMID14 CMID13 CMID12 CMID11 CMID10 CMID9 CMID8 CMID7 1 1 1 1 1 1 1 1 1 1 1 CMID6 CMID5 CMID4 CMID3 CMID2 CMID1 CMID0 1 1 1 1 1 1 1 1: Not compared (masked) 0: Compared 606 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 The CMID27 to CMID24 and CMID22 bits are cleared to 0, and the CMID28, CMID23, and CMID21 to CMID0 bits are set to 1. User's Manual U18743EE1V2UM00 607 Chapter 18 CAN Controller (CAN) 18.9.5 Multi buffer receive block function The multi buffer receive block (MBRB) function is used to store a block of data in two or more message buffers sequentially with no CPU interaction, by setting the same ID to two or more message buffers with the same message buffer type. These message buffers can be allocated anywhere in the message buffer memory, they do not even have to follow each other adjacently. Suppose, for example, the same message buffer type is set to 10 message buffers, message buffers 10 to 19, and the same ID is set to each message buffer. If the first message whose ID matches an ID of the message buffers is received, it is stored in message buffer 10. At this point, the DN bit of message buffer 10 is set, prohibiting overwriting the message buffer when subsequent messages are received. When the next message with a matching ID is received, it is received and stored in message buffer 11. Each time a message with a matching ID is received, it is sequentially (in the ascending order) stored in message buffers 12, 13, and so on. Even when a data block consisting of multiple messages is received, the messages can be stored and received without overwriting the previously received matching-ID data. Whether a data block has been received and stored can be checked by setting the IE bit of the CnMCTRLm register of each message buffer. For example, if a data block consists of k messages, k message buffers are initialized for reception of the data block. The IE bit in message buffers 0 to (k-2) is cleared to 0 (interrupts disabled), and the IE bit in message buffer k-1 is set to 1 (interrupts enabled). In this case, a reception completion interrupt occurs when a message has been received and stored in message buffer k-1, indicating that MBRB has become full. Alternatively, by clearing the IE bit of message buffers 0 to (k-3) and setting the IE bit of message buffer k-2, a warning that MBRB is about to overflow can be issued. The basic conditions of storing receive data in each message buffer for the MBRB are the same as the conditions of storing data in a single message buffer. Caution 1. MBRB can be configured for each of the same message buffer types. Therefore, even if a message buffer of another MBRB whose ID matches but whose message buffer type is different has a vacancy, the received message is not stored in that message buffer, but instead discarded. 2. MBRB does not have a ring buffer structure. Therefore, after a message is stored in the message buffer having the highest number in the MBRB configuration, a newly received message will not be stored in the message buffer having the lowest message buffer number. 3. MBRB operates based on the reception and storage conditions; there are no settings dedicated to MBRB, such as function enable bits. By setting the same message buffer type and ID to two or more message buffers, MBRB is automatically configured. 4. With MBRB, "matching ID" means "matching ID after mask". Even if the ID set to each message buffer is not the same, if the ID that is masked by the mask register matches, it is considered a matching ID and the buffer that has this ID is treated as the storage destination of a message. 5. The priority between MBRBs is mentioned in the table Table 18-24. 608 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.9.6 Remote frame reception In all the operation modes, when a remote frame is received, the message buffer that is to store the remote frame is searched from all the message buffers satisfying the following conditions. * Used as a message buffer (MA0 bit of CnMCONFm register set to 1.) * Set as a transmit message buffer (MT[2:0] bits in CnMCONFm register set to 000B) * Ready for reception (RDY bit of CnMCTRLm register set to 1.) * Set to transmit message (RTR bit of CnMCONFm register is cleared to 0.) * Transmission request is not set. (TRQ bit of CnMCTRLm register is cleared to 0.) Upon acceptance of a remote frame, the following actions are executed if the ID of the received remote frame matches the ID of a message buffer that satisfies the above conditions. * The DLC[3:0] bit string in the CnMDLCm register store the received DLC value. * The CnMDATA0m to CnMDATA7m registers in the data area are not updated (data before reception is saved). * The DN bit of the CnMCTRLm register is set to 1. * The CINTS1 bit of the CnINTS register is set to 1 (if the IE bit in the CnMCTRLm register of the message buffer that receives and stores the frame is set to 1). * The receive completion interrupt (INTCnREC) is output (if the IE bit of the message buffer that receives and stores the frame is set to 1 and if the CIE1 bit of the CnIE register is set to 1). * The message buffer number is recorded in the receive history list. Caution When a message buffer is searched for receiving and storing a remote frame, overwrite control by the OWS bit of the CnMCONFm register of the message buffer and the DN bit of the CnMCTRLm register are not checked. The setting of OWS is ignored, and DN is set in any case. If more than one transmit message buffer has the same ID and the ID of the received remote frame matches that ID, the remote frame is stored in the transmit message buffer with the lowest message buffer number. User's Manual U18743EE1V2UM00 609 Chapter 18 CAN Controller (CAN) 18.10 Message Transmission 18.10.1 Message transmission A message buffer with its TRQ bit set to 1 participates in the search for the most high-prioritized message when the following conditions are fulfilled. This behavior is valid for all operational modes. * Used as a message buffer (MA0 bit of CnMCONFm register set to 1.) * Set as a transmit message buffer (MT[2:0] bits of CnMCONFm register set to 000B.) * Ready for transmission (RDY bit of CnMCTRLm register set to 1.) The CAN system is a multi-master communication system. In a system like this, the priority of message transmission is determined based on message identifiers (IDs). To facilitate transmission processing by software when there are several messages awaiting transmission, the CAN module uses hardware to check the ID of the message with the highest priority and automatically identifies that message. This eliminates the need for software-based priority control. Transmission priority is controlled by the identifier (ID). Message No. Message waiting to be transmitted 0 1 ID = 120H 2 ID = 229H 3 4 5 ID = 223H 6 ID = 023H The CAN module transmits messages in the following sequence. 1. Message 6 2. Message 1 3. Message 8 4. Message 5 5. Message 2 7 8 ID = 123H 9 Figure 18-30 Message processing example After the transmit message search, the transmit message with the highest priority of the transmit message buffers that have a pending transmission request (message buffers with the TRQ bit set to 1 in advance) is transmitted. If a new transmission request is set, the transmit message buffer with the new transmission request is compared with the transmit message buffer with a pending transmission request. If the new transmission request has a higher priority, it is transmitted, unless transmission of a message with a low priority has already started. If transmission of a message with a low priority has already started, however, the new transmission request is transmitted later. To solve this priority inversion effect, the software can perform a transmission abort request for the lower priority message. The highest priority is determined according to the following rules. 610 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 Priority Conditions Description 1 (high) Value of first 11 bits of ID [ID28 to ID18]: The message frame with the lowest value represented by the first 11 bits of the ID is transmitted first. If the value of an 11-bit standard ID is equal to or smaller than the first 11 bits of a 29-bit extended ID, the 11-bit standard ID has a higher priority than a message frame with a 29-bit extended ID. 2 Frame type A data frame with an 11-bit standard ID (RTR bit is cleared to 0) has a higher priority than a remote frame with a standard ID and a message frame with an extended ID. 3 ID type A message frame with a standard ID (IDE bit is cleared to 0) has a higher priority than a message frame with an extended ID. 4 Value of lower 18 bits of ID [ID17 to ID0]: If two or more transmission-pending extended ID message frame has equal values in the first 11 bits of the ID and the same frame type (equal RTR bit values), the message frame with the lowest value in the lower 18 bits of its extended ID is transmitted first. 5 (low) Message buffer number If two or more message buffers request transmission of message frames with the same ID, the message from the message buffer with the lowest message buffer number is transmitted first. Note 1. If the automatic block transmission request bit ABTTRG is set to 1 in the normal operation mode with ABT, the TRQ bit is set to 1 only for one message buffer in the ABT message buffer group. If the ABT mode was triggered by ABTTRG bit (1), one TRQ bit is set to 1 in the ABT area (buffer 0 through 7). Beyond this TRQ bit, the application can request transmissions (set TRQ bit to 1) for other TX-message buffers that do not belong to the ABT area. In that case an interval arbitration process (TX-search) evaluates all TX-message buffers with TRQ bit set to 1 and chooses the message buffer that contains the highest prioritized identifier for the next transmission. If there are 2 or more identifiers that have the highest priority (i.e. identical identifiers), the message located at the lowest message buffer number is transmitted at first. Upon successful transmission of a message frame, the following operations are performed. * The TRQ flag of the corresponding transmit message buffer is automatically cleared to 0. * The transmission completion status bit CINTS0 of the CnINTS register is set to 1 (if the interrupt enable bit (IE) of the corresponding transmit message buffer is set to 1). * An interrupt request signal INTCnTRX is output (if the CIE0 bit of the CnIE register is set to 1 and if the interrupt enable bit (IE) of the corresponding transmit message buffer is set to 1). 2. When changing the contents of a transmit buffer, the RDY flag of this buffer must be cleared before updating the buffer contents. As during internal transfer actions, the RDY flag may be locked temporarily, the status of RDY must be checked by software, after changing it. User's Manual U18743EE1V2UM00 611 Chapter 18 CAN Controller (CAN) 18.10.2 Transmit history list function The transmit history list (THL) function records in the transmit history list the number of the transmit message buffer from which data or remote frames have been were sent. The THL consists of storage elements equivalent to up to seven messages, the last out-message pointer (LOPT) with the corresponding CnLOPT register, and the transmit history list get pointer (TGPT) with the corresponding CnTGPT register. The THL is undefined immediately after the transition of the CAN module from the initialization mode to one of the operation modes. The CnLOPT register holds the contents of the THL element indicated by the value of the LOPT pointer minus 1. By reading the CnLOPT register, therefore, the number of the message buffer that transmitted a data frame or remote frame first can be checked. The LOPT pointer is utilized as a write pointer that indicates to what part of the THL a message buffer number is recorded. Any time a data frame or remote frame is transmitted, the corresponding message buffer number is recorded to the THL element indicated by the LOPT pointer. Each time recording to the THL has been completed, the LOPT pointer is automatically incremented. In this way, the number of the message buffer that has received and stored a frame will be recorded chronologically. The TGPT pointer is utilized as a read pointer that reads a recorded message buffer number from the THL. This pointer indicates the first THL element that the CPU has not yet read. By reading the CnTGPT register by software, the number of a message buffer that has completed transmission can be read. Each time a message buffer number is read from the CnTGPT register, the TGPT pointer is automatically incremented. If the value of the TGPT pointer matches the value of the LOPT pointer, the THPM bit (transmit history list pointer match) of the CnTGPT register is set to 1. This indicates that no message buffer numbers that have not been read remain in the THL. If a new message buffer number is recorded, the LOPT pointer is incremented and because its value no longer matches the value of the TGPT pointer, the THPM bit is cleared. In other words, the numbers of the unread message buffers exist in the THL. If the LOPT pointer is incremented and matches the value of the TGPT pointer minus 1, the TOVF bit (transmit history list overflow) of the CnTGPT register is set to 1. This indicates that the THL is full of message buffer numbers that have not been read. If a new message is received and stored, the message buffer number recorded last is overwritten by the message buffer number that transmitted its message afterwards. In this case, after the TOVF bit has been set (1), therefore, the recorded message buffer numbers in the THL do not completely reflect the chronological order. However the other transmitted messages can be found by a CPU search applied to all transmit message buffers unless the CPU has not overwritten a transmit object in one of these buffers beforehand. In total up to six transmission completions can occur without overflowing the THL. 612 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Caution Chapter 18 If the history list is in the overflow condition (TOVF is set), reading the history list contents is still possible, until the history list is empty (indicated by THPM flag set). Nevertheless, the history list remains in the overflow condition, until TOVF is cleared by software. If TOVF is not cleared, the THPM flag will also not be updated (cleared) upon successful transmission of a new message. This may lead to the situation, that THPM indicates an empty history list, although a successful transmission has taken place, while the history list is in the overflow state (TOVF and THPM are set). Transmit history list (THL) Last outmessage pointer (LOPT) 7 6 5 4 3 2 1 0 Transmit history list (THL) Event: Message buffer 7 Message buffer 2 Message buffer 9 Message buffer 6 - CPU confirms Tx completion of message buffer 6, 9, and 2. Last out- Tx completion of message message buffer 3, and 4. pointer (LOPT) Transmit history list get pointer (TGPT) 7 6 5 4 3 2 1 0 Message buffer 4 Message buffer 3 Message buffer 7 Transmit history list get pointer (TGPT) Event: - Message buffer 8, 5, 6, and 10 completes transmission. - THL is full. - TOVF is set. Transmit history list (THL) Last outmessage pointer (LOPT) 7 6 5 4 3 2 1 0 Message buffer 5 Message buffer 8 Message buffer 4 Message buffer 3 Message buffer 7 Message buffer 10 Message buffer 6 Transmit history list (THL) Event: - Message buffer11, 13, and 14 completes transmission. - Overflow situation occurs. Transmit history list get pointer (TGPT) TOVF = 1 LOPT is blocked 7 6 5 4 3 2 1 0 Message buffer 5 Message buffer 8 Message buffer 4 Message buffer 3 Message buffer 7 Last outMessage buffer 14 message Message buffer 6 pointer (LOPT) TOVF = 1 LOPT is blocked Transmit history list get pointer (TGPT) TOVF = 1 denotes that LOPT equals TGPT - 1 while message buffer number stored to element indicated by LOPT - 1. Figure 18-31 Transmit history list User's Manual U18743EE1V2UM00 613 Chapter 18 CAN Controller (CAN) 18.10.3 Automatic block transmission (ABT) The automatic block transmission (ABT) function is used to transmit two or more data frames successively with no CPU interaction. The maximum number of transmit message buffers assigned to the ABT function is eight (message buffer numbers 0 to 7). By setting the OPMODE[2:0] bits of the CnCTRL register to 010B, "normal operation mode with automatic block transmission function" (hereafter referred to as ABT mode) can be selected. To issue an ABT transmission request, define the message buffers by software first. Set the MA0 bit (1) in all the message buffers used for ABT, and define all the buffers as transmit message buffers by setting the MT[2:0] bits to 000B. Be sure to set the same ID for the message buffers for ABT even when that ID is being used for all the message buffers. To use two or more IDs, set the ID of each message buffer by using the CnMIDLm and CnMIDHm registers. Set the CnMDLCm and CnMDATA0m to CnMDATA7m registers before issuing a transmission request for the ABT function. After initialization of message buffers for ABT is finished, the RDY bit needs to be set (1). In the ABT mode, the TRQ bit does not have to be manipulated by software. After the data for the ABT message buffers has been prepared, set the ABTTRG bit to 1. Automatic block transmission is then started. When ABT is started, the TRQ bit in the first message buffer (message buffer 0) is automatically set to 1. After transmission of the data of message buffer 0 is finished, the TRQ bit of the next message buffer, message buffer 1, is set automatically. In this way, transmission is executed successively. A delay time can be inserted by program in the interval in which the transmission request (TRQ ) is automatically set while successive transmission is being executed. The delay time to be inserted is defined by the CnGMABTD register. The unit of the delay time is DBT (data bit time). DBT depends on the setting of the CnBRP and CnBTR registers. Among transmit objects within the ABT-area, the priority of the transmission ID is not evaluated. The data of message buffers 0 to 7 are sequentially transmitted. When transmission of the data frame from message buffer 7 has been completed, the ABTTRG bit is automatically cleared to 0 and the ABT operation is finished. If the RDY bit of an ABT message buffer is cleared during ABT, no data frame is transmitted from that buffer, ABT is stopped, and the ABTTRG bit is cleared. After that, transmission can be resumed from the message buffer where ABT stopped, by setting the RDY and ABTTRG bits to 1 by software. To not resume transmission from the message buffer where ABT stopped, the internal ABT engine can be reset by setting the ABTCLR bit to 1 while ABT mode is stopped and the ABTTRG bit is cleared to 0. In this case, transmission is started from message buffer 0 if the ABTCLR bit is cleared to 0 and then the ABTTRG bit is set to 1. An interrupt can be used to check if data frames have been transmitted from all the message buffers for ABT. To do so, the IE bit of the CnMCTRLm register of each message buffer except the last message buffer needs to be cleared (0). If a transmit message buffer other than those used by the ABT function (message buffers 8 to 31) is assigned to a transmit message buffer, the message to be transmitted next is determined by the priority of the transmission ID of the ABT message buffer whose transmission is currently 614 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 held pending and the transmission ID of the message buffers other than those used by the ABT function. Transmission of a data frame from an ABT message buffer is not recorded in the transmit history list (THL). Caution 1. Set the ABTCLR bit to 1 while the ABTTRG bit is cleared to 0 in order to resume ABT operation at buffer No.0. If the ABTCLR bit is set to 1 while the ABTTRG bit is set to 1, the subsequent operation is not guaranteed. 2. If the automatic block transmission engine is cleared by setting the ABTCLR bit to 1, the ABTCLR bit is automatically cleared immediately after the processing of the clearing request is completed. 3. Do not set the ABTTRG bit in the initialization mode. If the ABTTRG bit is set in the initialization mode, the proper operation is not guaranteed after the mode is changed from the initialization mode to the ABT mode. 4. Do not set the TRQ bit of the ABT message buffers to 1 by software in the normal operation mode with ABT. Otherwise, the operation is not guaranteed. 5. The CnGMABTD register is used to set the delay time that is inserted in the period from completion of the preceding ABT message to setting of the TRQ bit for the next ABT message when the transmission requests are set in the order of message numbers for each message for ABT that is successively transmitted in the ABT mode. The timing at which the messages are actually transmitted onto the CAN bus varies depending on the status of transmission from other stations and the status of the setting of the transmission request for messages other than the ABT messages (message buffers 8 to 31). 6. If a transmission request is made for a message other than an ABT message and if no delay time is inserted in the interval in which transmission requests for ABT are automatically set (CnGMABTD register = 00H), messages other than ABT messages may be transmitted not depending on their priority compared to the priority of the ABT message. 7. Do not clear the RDY bit to 0 when the ABTTRG bit = 1. 8. If a message is received from another node while normal operation mode with ABT is active, the TX-message from the ABT-area may be transmitted with delay of one frame although CnGMABTD register was set up with 00H. User's Manual U18743EE1V2UM00 615 Chapter 18 CAN Controller (CAN) 18.10.4 Transmission abort process (1) Transmission abort process except for in normal operation mode with automatic block transmission (ABT) The user can clear the TRQ bit of the CnMCTRLm register to 0 to abort a transmission request. The TRQ bit will be cleared immediately if the abort was successful. Whether the transmission was successfully aborted or not can be checked using the TSTAT bit of the CnCTRL register and the CnTGPT register, which indicate the transmission status on the CAN bus (for details, refer to the processing in Figure 18-45 on page 647). (2) Transmission abort process except for ABT transmission in normal operation mode with automatic block transmission (ABT) The user can clear the ABTTRG bit of the CnGMABT register to 0 to abort a transmission request. After checking the ABTTRG bit of the CnGMABT register = 0, clear the TRQ bit of the CnMCTRLm register to 0. The TRQ bit will be cleared immediately if the abort was successful. Whether the transmission was successfully aborted or not can be checked using the TSTAT bit of the CnCTRL register and the CnTGPT register, which indicate the transmission status on the CAN bus (for details, refer to the processing in Figure 18-46 on page 648). (3) Transmission abort process for ABT transmission in normal operation mode with automatic block transmission (ABT) To abort ABT that is already started, clear the ABTTRG bit of the CnGMABT register to 0. In this case, the ABTTRG bit remains 1 if an ABT message is currently being transmitted and until the transmission is completed (successfully or not), and is cleared to 0 as soon as transmission is finished. This aborts ABT. If the last transmission (before ABT) was successful, the normal operation mode with ABT is left with the internal ABT pointer pointing to the next message buffer to be transmitted. In the case of an erroneous transmission, the position of the internal ABT pointer depends on the status of the TRQ bit in the last transmitted message buffer. If the TRQ bit is set to 1 when clearing the ABTTRG bit is requested, the internal ABT pointer points to the last transmitted message buffer (for details, refer to the process in Figure 18-47 on page 649). If the TRQ bit is cleared to 0 when clearing the ABTTRG bit is requested, the internal ABT pointer is incremented (+1) and points to the next message buffer in the ABT area (for details, refer to the process in Figure 18-48 on page 650). Caution Be sure to abort ABT by clearing ABTTRG bit to 0. The operation is not guaranteed if aborting transmission is requested by clearing RDY. When the normal operation mode with ABT is resumed after ABT has been aborted and the ABTTRG bit is set to 1, the next ABT message buffer to be transmitted can be determined from the following table. 616 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 Status of TRQ of ABT message buffer Abort after successful transmission Abort after erroneous transmission Set (1) Next message buffer in the ABT areaa Same message buffer in the ABT area a Next message buffer in the ABT areaa Cleared (0) a) Next message buffer in the ABT area The above resumption operation can be performed only if a message buffer ready for ABT exists in the ABT area. For example, an abort request that is issued while ABT of message buffer 7 is in progress is regarded as completion of ABT, rather than abort, if transmission of message buffer 7 has been successfully completed, even if the ABTTRG bit is cleared to 0. If the RDY bit in the next message buffer in the ABT area is cleared to 0, the internal ABT pointer is retained, but the resumption operation is not performed even if the ABTTRG bit is set to 1, and ABT ends immediately. 18.10.5 Remote frame transmission Remote frames can be transmitted only from transmit message buffers. Set whether a data frame or remote frame is transmitted via the RTR bit of the CnMCONFm register. Setting (1) the RTR bit sets remote frame transmission. User's Manual U18743EE1V2UM00 617 Chapter 18 CAN Controller (CAN) 18.11 Power Saving Modes 18.11.1 CAN sleep mode The CAN sleep mode can be used to set the CAN Controller to stand-by mode in order to reduce power consumption. The CAN module can enter the CAN sleep mode from all operation modes. Release of the CAN sleep mode returns the CAN module to exactly the same operation mode from which the CAN sleep mode was entered. In the CAN sleep mode, the CAN module does not transmit messages, even when transmission requests are issued or pending. (1) Entering CAN sleep mode The CPU issues a CAN sleep mode transition request by writing 01B to the PSMODE[1:0] bits of the CnCTRL register. This transition request is acknowledged only under the following conditions. 1. The CAN module is already in one of the following operation modes - Normal operation mode - Normal operation mode with ABT - Receive-only mode - Single-shot mode - Self-test mode - CAN stop mode in all the above operation modes 2. The CAN bus state is bus idle (the 4th bit in the interframe space is recessive). If the CAN bus is fixed to dominant, the request for transition to the CAN sleep mode is held pending. Also the transition from CAN stop mode to CAN sleep mode is independent of the CAN bus state. 3. No transmission request is pending Note If a sleep mode request is pending, and at the same time a message is received in a message box, the sleep mode request is not cancelled, but is executed right after message storage has been finished. This may result in AFCAN being in sleep mode, while the CPU would execute the RX interrupt routine. Therefore, the interrupt routine must check the access to the message buffers as well as reception history list registers by using the MBON flag, if sleep mode is used. Similarly, if a sleep mode request is pending, and at the same time a message is transmitted in a message box, the sleep mode request is not cancelled, but is executed. This may result in CAN being in sleep mode, while the CPU would execute the transmit interrupt routine. Therefore, the interrupt routine must check the access to the message buffers as well as transmission history list registers by using the MBON flag, if sleep mode is used. If any one of the conditions mentioned above is not met, the CAN module will operate as follows. * If the CAN sleep mode is requested from the initialization mode, the CAN sleep mode transition request is ignored and the CAN module remains in the initialization mode. * If the CAN bus state is not bus idle (i.e., the CAN bus state is either transmitting or receiving) when the CAN sleep mode is requested in one of 618 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 the operation modes, immediate transition to the CAN sleep mode is not possible. In this case, the CAN sleep mode transition request has to be held pending until the CAN bus state becomes bus idle (the 4th bit in the interframe space is recessive). In the time from the CAN sleep mode request to successful transition, the PSMODE[1:0] bits remain 00B. When the module has entered the CAN sleep mode, the PSMODE[1:0] bits are set to 01B. * If a request for transition to the initialization mode and a request for transition to the CAN sleep mode are made at the same time while the CAN module is in one of the operation modes, the request for the initialization mode is enabled. The CAN module enters the initialization mode at a predetermined timing. At this time, the CAN sleep mode request is not held pending and is ignored. * Even when initialization mode and sleep mode are not requested simultaneously (i.e the first request has not been granted while the second request is made), the request for initialization has priority over the sleep mode request. The sleep mode request is cancelled when the initialization mode is requested. When a pending request for initialization mode is present, a subsequent request for Sleep mode request is cancelled right at the point in time where it was submitted. (2) Status in CAN sleep mode The CAN module is in the following state after it enters the CAN sleep mode: * The internal operating clock is stopped and the power consumption is minimized. * The function to detect the falling edge of the CAN reception pin (CRXDn) remains in effect to wake up the CAN module from the CAN bus. * To wake up the CAN module from the CPU, data can be written to the PSMODE[1:0] bits of the CAN module control register (CnCTRL), but nothing can be written to other CAN module registers or bits. * The CAN module registers can be read, except for the CnLIPT, CnRGPT, CnLOPT, and CnTGPT registers. * The CAN message buffer registers cannot be written or read. * MBON bit of the CAN Global Control register (CnGMCTRL) is cleared. * A request for transition to the initialization mode is not acknowledged and is ignored. User's Manual U18743EE1V2UM00 619 Chapter 18 CAN Controller (CAN) (3) Releasing CAN sleep mode The CAN sleep mode is released by the following events: * When the CPU writes 00B to the PSMODE[1:0] bits of the CnCTRL register * A falling edge at the CAN reception pin (CRXDn) (i.e. the CAN bus level shifts from recessive to dominant) Caution Even if the falling edge belongs to the SOF of a receive message, this message will not be received and stored. If the CPU has turned off the clock supply to the CAN module while the CAN module was in sleep mode, even subsequently the CAN sleep mode will not be released and PSMODE [1:0] will remain 01B unless the clock to the CAN module is supplied again. In addition to this, the receive message will not be received after that. After releasing the sleep mode, the CAN module returns to the operation mode from which the CAN sleep mode was requested and the PSMODE[1:0] bits of the CnCTRL register must be reset by software to 00B. If the CAN sleep mode is released by a change in the CAN bus state, the CINTS5 bit of the CnINTS register is set to 1, regardless of the CIE bit of the CnIE register. After the CAN module is released from the CAN sleep mode, it participates in the CAN bus again by automatically detecting 11 consecutive recessive-level bits on the CAN bus. The user application has to wait until MBON = 1, before accessing message buffers again. When a request for transition to the initialization mode is made while the CAN module is in the CAN sleep mode, that request is ignored; the CAN module has to be released from sleep mode by software first before entering the initialization mode. Caution 1. Be aware that the release of CAN sleep mode by CAN bus event, and thus the wake up interrupt may happen at any time, even right after requesting sleep mode, if a CAN bus event occurs. 2. Always reset the PSMODE[1:0] bits to 00B, when waking up from CAN sleep mode, before accessing any other registers of the CAN module. 3. Always clear the interrupt flag CINTS5, when waking up from CAN sleep mode. 620 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.11.2 CAN stop mode The CAN stop mode can be used to set the CAN Controller to stand-by mode to reduce power consumption. The CAN module can enter the CAN stop mode only from the CAN sleep mode. Release of the CAN stop mode puts the CAN module in the CAN sleep mode. The CAN stop mode can only be released (entering CAN sleep mode) by writing 01B to the PSMODE[1:0] bits of the CnCTRL register and not by a change in the CAN bus state. No message is transmitted even when transmission requests are issued or pending. (1) Entering CAN stop mode A CAN stop mode transition request is issued by writing 11B to the PSMODE[1:0] bits of the CnCTRL register. A CAN stop mode request is only acknowledged when the CAN module is in the CAN sleep mode. In all other modes, the request is ignored. Caution (2) To set the CAN module to the CAN stop mode, the module must be in the CAN sleep mode. To confirm that the module is in the sleep mode, check that the PSMODE[1:0] bits = 01B, and then request the CAN stop mode. If a bus change occurs at the CAN reception pin (CRXDn) while this process is being performed, the CAN sleep mode is automatically released. In this case, the CAN stop mode transition request cannot be acknowledged. Status in CAN stop mode The CAN module is in the following state after it enters the CAN stop mode. * The internal operating clock is stopped and the power consumption is minimized. * To wake up the CAN module from the CPU, data can be written to the PSMODE[1:0] bits of the CAN module control register (CnCTRL), but nothing can be written to other CAN module registers or bits. * The CAN module registers can be read, except for the CnLIPT, CnRGPT, CnLOPT, and CnTGPT registers. * The CAN message buffer registers cannot be written or read. * MBON bit of the CAN Global Control register (CnGMCTRL) is cleared. * An initialization mode transition request is not acknowledged and is ignored. (3) Releasing CAN stop mode The CAN stop mode can only be released by writing 01B to the PSMODE[1:0] bits of the CnCTRL register. After releasing the CAN stop mode, the CAN module enters the CAN sleep mode. When the initialization mode is requested while the CAN module is in the CAN stop mode, that request is ignored; the CPU has to release the stop mode and subsequently CAN sleep mode before entering the initialization mode. It is impossible to enter the other operation mode directly from the CAN stop mode not entering the CAN sleep mode, that request is ignored. User's Manual U18743EE1V2UM00 621 Chapter 18 CAN Controller (CAN) 18.11.3 Example of using power saving modes In some application systems, it may be necessary to place the CPU in a power saving mode to reduce the power consumption. By using the power saving mode specific to the CAN module and the power saving mode specific to the CPU in combination, the CPU can be woken up from the power saving status by the CAN bus. Here is an example for using the power saving modes. * First, put the CAN module in the CAN sleep mode (PSMODE[1:0] = 01B). Next, put the CPU in the power saving mode. If an edge transition from recessive to dominant is detected at the CAN reception pin (CRXDn) in this status, the CINTS5 bit in the CAN module is set to 1. If the CIE5 bit of the CnCTRL register is set to 1, a wakeup interrupt (INTWUPn) is generated. * The CAN module is automatically released from CAN sleep mode (PSMODE = 00B) and returns to normal operation mode. * The CPU, in response to INTWUPn, can release its own power saving mode and return to normal operation mode. To further reduce the power consumption of the CPU, the internal clock - including that of the CAN module - may be stopped. In this case, the operating clock supplied to the CAN module is stopped after the CAN module has been put in CAN sleep mode. Then the CPU enters a power saving mode in which the clock supplied to the CPU is stopped. * If an edge transition from recessive to dominant is detected at the CAN reception pin (CRXDn) in this status, the CAN module can set the CINTS5 bit to 1 and generate the wakeup interrupt (INTWUPn) even if it is not supplied with the clock. * The other functions, however, do not operate, because clock supply to the CAN module is stopped, and the module remains in CAN sleep mode. * The CPU, in response to INTWUPn - releases its power saving mode, - resumes supply of the internal clocks - including the clock to the CAN module - after the oscillation stabilization time has elapsed, and - starts instruction execution. * The CAN module is immediately released from the CAN sleep mode when clock supply is resumed, and returns to the normal operation mode (PSMODE = 00B). 622 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.12 Interrupt Function The CAN module provides 6 different interrupt sources. The occurrence of these interrupt sources is stored in interrupt status registers. Four separate interrupt request signals are generated from the six interrupt sources. When an interrupt request signal that corresponds to two or more interrupt sources is generated, the interrupt sources can be identified by using an interrupt status register. After an interrupt source has occurred, the corresponding interrupt status bit must be cleared to 0 by software. Table 18-25 List of CAN module interrupt sources Interrupt status bit Name Register Name Register Interrupt request signal 1 CINTS0 CnINTS CIE0a CnIE INTCnTRX Message frame successfully transmitted from message buffer m 2 CINTS1 CnINTS CIE1a CnIE INTCnREC Valid message frame reception in message buffer m 3 CINTS2 CnINTS CIE2 CnIE INTCnERR CAN module error state interrupt (Supplement 1) 4 CINTS3 CnINTS CIE3 CnIE CAN module protocol error interrupt (Supplement 2) 5 CINTS4 CnINTS CIE4 CnIE CAN module arbitration loss interrupt 6 CINTS5 CnINTS CIE5 CnIE No. a) Interrupt enable bit INTCnWUP Interrupt source description CAN module wakeup interrupt from CAN sleep mode (Supplement 3) The IE bit (message buffer interrupt enable bit) in the CnMCTRL register of the corresponding message buffer has to be set to 1 for that message buffer to participate in the interrupt generation process. Supplements 1. This interrupt is generated when the transmission/reception error counter is at the warning level, or in the error passive or bus-off state. 2. This interrupt is generated when a stuff error, form error, ACK error, bit error, or CRC error occurs. 3. This interrupt is generated when the CAN module is woken up from the CAN sleep mode because a falling edge is detected at the CAN reception pin (CAN bus transition from recessive to dominant). User's Manual U18743EE1V2UM00 623 Chapter 18 CAN Controller (CAN) 18.13 Diagnosis Functions and Special Operational Modes The CAN module provides a receive-only mode, single-shot mode, and self-test mode to support CAN bus diagnosis functions or the operation of special CAN communication methods. 18.13.1 Receive-only mode The receive-only mode is used to monitor receive messages without causing any interference on the CAN bus and can be used for CAN bus analysis nodes. For example, this mode can be used for automatic baud-rate detection. The baud rate in the CAN module is changed until "valid reception" is detected, so that the baud rates in the module match ("valid reception" means a message frame has been received in the CAN protocol layer without occurrence of an error and with an appropriate ACK between nodes connected to the CAN bus). A valid reception does not require message frames to be stored in a receive message buffer (data frames) or transmit message buffer (remote frames). The event of valid reception is indicated by setting the VALID bit of the CnCTRL register (1). CAN macro Tx Rx Fixed to the recessive level CTXDn Figure 18-32 CRXDn CAN module terminal connection in receive-only mode In the receive-only mode, no message frames can be transmitted from the CAN module to the CAN bus. Transmit requests issued for message buffers defined as transmit message buffers are held pending. In the receive-only mode, the CAN transmission pin (CTXDn) in the CAN module is fixed to the recessive level. Therefore, no active error flag can be transmitted from the CAN module to the CAN bus even when a CAN bus error is detected while receiving a message frame. Since no transmission can be issued from the CAN module, the transmission error counter the CnERC.TEC7 to CnERC.TEC0 bits are never updated. Therefore, a CAN module in the receive-only mode does not enter the bus-off state. 624 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 Furthermore, in the receive-only mode ACK is not returned to the CAN bus in this mode upon the valid reception of a message frame. Internally, the local node recognizes that it has transmitted ACK. An overload frame cannot be transmitted to the CAN bus. Caution If only two CAN nodes are connected to the CAN bus and one of them is operating in the receive-only mode, there is no ACK on the CAN bus. Due to the missing ACK, the transmitting node will transmit an active error flag, and repeat transmitting a message frame. The transmitting node becomes error passive after transmitting the message frame 16 times (assuming that the error counter was 0 in the beginning and no other errors have occurred). After the message frame for the 17th time is transmitted, the transmitting node generates a passive error flag. The receiving node in the receive-only mode detects the first valid message frame at this point, and the VALID bit is set to 1 for the first time. 18.13.2 Single-shot mode In the single-shot mode, automatic re-transmission as defined in the CAN protocol is switched off. (According to the CAN protocol, a message frame transmission that has been aborted by either arbitration loss or error occurrence has to be repeated without control by software.) All other behavior of single shot mode is identical to normal operation mode. Features of single shot mode can not be used in combination with normal mode with ABT. The single-shot mode disables the re-transmission of an aborted message frame transmission according to the setting of the AL bit of the CnCTRL register. When the AL bit is cleared to 0, re-transmission upon arbitration loss and upon error occurrence is disabled. If the AL bit is set to 1, re-transmission upon error occurrence is disabled, but re-transmission upon arbitration loss is enabled. As a consequence, the TRQ bit in a message buffer defined as a transmit message buffer is cleared to 0 by the following events: * Successful transmission of the message frame * Arbitration loss while sending the message frame * Error occurrence while sending the message frame The events arbitration loss and error occurrence can be distinguished by checking the CINTS4 and CINTS3 bits of the CnINTS register respectively, and the type of the error can be identified by reading the LEC[2:0] bits of the CnLEC register. Upon successful transmission of the message frame, the transmit completion interrupt bit CINTS0 of the CnINTS register is set to 1. If the CIE0 bit of the CnIE register is set to 1 at this time, an interrupt request signal is output. User's Manual U18743EE1V2UM00 625 Chapter 18 CAN Controller (CAN) The single-shot mode can be used when emulating time-triggered communication methods (e.g., TTCAN level 1). Caution The AL bit is only valid in single-shot mode. It does not influence the operation of re-transmission upon arbitration loss in the other operation modes. 18.13.3 Self-test mode In the self-test mode, message frame transmission and message frame reception can be tested without connecting the CAN node to the CAN bus or without affecting the CAN bus. In the self-test mode, the CAN module is completely disconnected from the CAN bus, but transmission and reception are internally looped back. The CAN transmission pin (CTXDn) is fixed to the recessive level. If the falling edge on the CAN reception pin (CRXDn) is detected after the CAN module has entered the CAN sleep mode from the self-test mode, however, the module is released from the CAN sleep mode in the same manner as the other operation modes. To keep the module in the CAN sleep mode, use the CAN reception pin (CRXDn) as a port pin. CAN macro Tx Rx Fixed to the recessive level CTXDn Figure 18-33 626 CRXDn CAN module terminal connection in self-test mode User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.13.4 Receive/transmit operation in each operation mode The following table shows outline of the receive/transmit operation in each operation mode. Table 18-26 Outline of the receive/transmit in each operation mode Operation mode Transmission of data/ remote frame Transmission of ACK Transmission of error/ overload frame Transmission retry Automatic block transmission (ABT) Set of VALID bit Store data to message buffer Initialization mode No No No No No No No Normal operation mode Yes Yes Yes Yes No Yes Yes Normal operation mode with ABT Yes Yes Yes Yes Yes Yes Yes Receive only mode No No No No No Yes Yes Single-shot mode Yes Yes Yes Noa No Yes Yes Self-test mode Yesb Yesb Yesb Yesb No Yesb Yesb a) b) When the arbitration lost occurs, control of re-transmission is possible by the AL bit of CnCTRL register. Each signals are not generated to outside, but generated into the CAN module. User's Manual U18743EE1V2UM00 627 Chapter 18 CAN Controller (CAN) 18.14 Time Stamp Function CAN is an asynchronous, serial protocol. All nodes connected to the CAN bus have a local, autonomous clock. As a consequence, the clocks of the nodes have no relation (i.e., the clocks are asynchronous and may have different frequencies). In some applications, however, a common time base over the network (= global time base) is needed. In order to build up a global time base, a time stamp function is used. The essential mechanism of a time stamp function is the capture of timer values triggered by signals on the CAN bus. 18.14.1 Time stamp function The CAN Controller supports the capturing of timer values triggered by a specific frame. An on-chip 16-bit capture timer unit in a microcontroller system is used in addition to the CAN Controller. The 16-bit capture timer unit captures the timer value according to a trigger signal (TSOUT) for capturing that is output when a data frame is received from the CAN Controller. The CPU can retrieve the time of occurrence of the capture event, i.e., the time stamp of the message received from the CAN bus, by reading the captured value. The TSOUT signal can be selected from the following two event sources and is specified by the TSSEL bit of the CnTS register. * SOF event (start of frame) (TSSEL = 0) * EOF event (last bit of end of frame) (TSSEL = 1) The TSOUT signal is enabled by setting the TSEN bit of the CnTS register to 1. SOF SOF SOF SOF TSOUT t Figure 18-34 Timing diagram of capture signal TSOUT The TSOUT signal toggles its level upon occurrence of the selected event during data frame reception (in Figure 18-34, the SOF is used as the trigger event source). To capture a timer value by using the TSOUT signal, the capture timer unit must detect the capture signal at both the rising edge and falling edge. This time stamp function is controlled by the TSLOCK bit of the CnTS register. When TSLOCK is cleared to 0, the TSOUT signal toggles upon occurrence of the selected event. If TSLOCK is set to 1, the TSOUT signal toggles upon occurrence of the selected event, but the toggle is stopped as the TSEN bit is automatically cleared to 0 as soon as the message storing to the message buffer 0 starts. This suppresses the subsequent toggle occurrence by the TSOUT signal, so that the time stamp value toggled last (= captured last) can be saved as the time stamp value of the time at which the data frame was received in message buffer 0. 628 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Caution Chapter 18 The time stamp function using the TSLOCK bit stops toggle of the TSOUT signal by receiving a data frame in message buffer 0. Therefore, message buffer 0 must be set as a receive message buffer. Since a receive message buffer cannot receive a remote frame, toggle of the TSOUT signal cannot be stopped by reception of a remote frame. Toggle of the TSOUT signal does not stop when a data frame is received in a message buffer other than message buffer 0. For these reasons, a data frame cannot be received in message buffer 0 when the CAN module is in the normal operation mode with ABT, because message buffer 0 must be set as a transmit message buffer. In this operation mode, therefore, the function to stop toggle of the TSOUT signal by the TSLOCK bit cannot be used. 18.15 Baud Rate Settings 18.15.1 Baud rate setting conditions Make sure that the settings are within the range of limit values for ensuring correct operation of the CAN Controller, as follows. * 5TQ SPT (sampling point) 17 TQ SPT = TSEG1 + 1 * 8 TQ DBT (data bit time) 25 TQ DBT = TSEG1 + TSEG2 + 1TQ = TSEG2 + SPT * 1 TQ SJW (synchronization jump width) 4TQ SJW DBT - SPT * 4 TSEG1 16 [3 Setting value of TSEG1[3:0] 15] * 1 TSEG2 8 [0 Setting value of TSEG2[2:0] 7] Note 1. TQ = 1/fTQ (fTQ: CAN protocol layer basic system clock) 2. TSEG1[3:0] (Bits 3 to 0 of CAN bit rate register (CnBTR)) 3. TSEG2[2:0] (Bits 10 to 8 of CAN bit rate register (CnBTR)) User's Manual U18743EE1V2UM00 629 Chapter 18 CAN Controller (CAN) Table 18-27 shows the combinations of bit rates that satisfy the above conditions. Table 18-27 Settable bit rate combinations (1/3) CnBTR register setting value Valid bit rate setting Sampling point (unit %) DBT length SYNC SEGMENT PROP SEGMENT PHASE SEGMENT1 PHASE SEGMENT2 TSEG1 [3:0] TSEG2 [2:0] 25 1 8 8 8 1111 111 68.0 24 1 7 8 8 1110 111 66.7 24 1 9 7 7 1111 110 70.8 23 1 6 8 8 1101 111 65.2 23 1 8 7 7 1110 110 69.6 23 1 10 6 6 1111 101 73.9 22 1 5 8 8 1100 111 63.6 22 1 7 7 7 1101 110 68.2 22 1 9 6 6 1110 101 72.7 22 1 11 5 5 1111 100 77.3 21 1 4 8 8 1011 111 61.9 21 1 6 7 7 1100 110 66.7 21 1 8 6 6 1101 101 71.4 21 1 10 5 5 1110 100 76.2 21 1 12 4 4 1111 011 81.0 20 1 3 8 8 1010 111 60.0 20 1 5 7 7 1011 110 65.0 20 1 7 6 6 1100 101 70.0 20 1 9 5 5 1101 100 75.0 20 1 11 4 4 1110 011 80.0 20 1 13 3 3 1111 010 85.0 19 1 2 8 8 1001 111 57.9 19 1 4 7 7 1010 110 63.2 19 1 6 6 6 1011 101 68.4 19 1 8 5 5 1100 100 73.7 19 1 10 4 4 1101 011 78.9 19 1 12 3 3 1110 010 84.2 19 1 14 2 2 1111 001 89.5 18 1 1 8 8 1000 111 55.6 18 1 3 7 7 1001 110 61.1 18 1 5 6 6 1010 101 66.7 18 1 7 5 5 1011 100 72.2 18 1 9 4 4 1100 011 77.8 18 1 11 3 3 1101 010 83.3 18 1 13 2 2 1110 001 88.9 18 1 15 1 1 1111 000 94.4 17 1 2 7 7 1000 110 58.8 630 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Table 18-27 Chapter 18 Settable bit rate combinations (2/3) CnBTR register setting value Valid bit rate setting Sampling point (unit %) DBT length SYNC SEGMENT PROP SEGMENT PHASE SEGMENT1 PHASE SEGMENT2 TSEG1 [3:0] TSEG2 [2:0] 17 1 4 6 6 1001 101 64.7 17 1 6 5 5 1010 100 70.6 17 1 8 4 4 1011 011 76.5 17 1 10 3 3 1100 010 82.4 17 1 12 2 2 1101 001 88.2 17 1 14 1 1 1110 000 94.1 16 1 1 7 7 0111 110 56.3 16 1 3 6 6 1000 101 62.5 16 1 5 5 5 1001 100 68.8 16 1 7 4 4 1010 011 75.0 16 1 9 3 3 1011 010 81.3 16 1 11 2 2 1100 001 87.5 16 1 13 1 1 1101 000 93.8 15 1 2 6 6 0111 101 60.0 15 1 4 5 5 1000 100 66.7 15 1 6 4 4 1001 011 73.3 15 1 8 3 3 1010 010 80.0 15 1 10 2 2 1011 001 86.7 15 1 12 1 1 1100 000 93.3 14 1 1 6 6 0110 101 57.1 14 1 3 5 5 0111 100 64.3 14 1 5 4 4 1000 011 71.4 14 1 7 3 3 1001 010 78.6 14 1 9 2 2 1010 001 85.7 14 1 11 1 1 1011 000 92.9 13 1 2 5 5 0110 100 61.5 13 1 4 4 4 0111 011 69.2 13 1 6 3 3 1000 010 76.9 13 1 8 2 2 1001 001 84.6 13 1 10 1 1 1010 000 92.3 12 1 1 5 5 0101 100 58.3 12 1 3 4 4 0110 011 66.7 12 1 5 3 3 0111 010 75.0 User's Manual U18743EE1V2UM00 631 Chapter 18 CAN Controller (CAN) Table 18-27 Settable bit rate combinations (3/3) CnBTR register setting value Valid bit rate setting Sampling point (unit %) DBT length SYNC SEGMENT PROP SEGMENT PHASE SEGMENT1 PHASE SEGMENT2 TSEG1 [3:0] TSEG2 [2:0] 12 1 7 2 2 1000 001 83.3 12 1 9 1 1 1001 000 91.7 11 1 2 4 4 0101 011 63.6 11 1 4 3 3 0110 010 72.7 11 1 6 2 2 0111 001 81.8 11 1 8 1 1 1000 000 90.9 10 1 1 4 4 0100 011 60.0 10 1 3 3 3 0101 010 70.0 10 1 5 2 2 0110 001 80.0 10 1 7 1 1 0111 000 90.0 9 1 2 3 3 0100 010 66.7 9 1 4 2 2 0101 001 77.8 9 1 6 1 1 0110 000 88.9 8 1 1 3 3 0011 010 62.5 8 1 3 2 2 0100 001 75.0 8 1 5 1 1 0101 000 87.5 7a 1 2 2 2 0011 001 71.4 7a 1 4 1 1 0100 000 85.7 a 6 1 1 2 2 0010 001 66.7 6a 1 3 1 1 0011 000 83.3 5a 1 2 1 1 0010 000 80.0 a 1 1 1 1 0001 000 75.0 4 a) Setting with a DBT value of 7 or less is valid only when the value of the CnBRP register is other than 00H. Caution 632 The values in Table 18-27 do not guarantee the operation of the network system. Thoroughly check the effect on the network system, taking into consideration oscillation errors and delays of the CAN bus and CAN transceiver. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.15.2 Representative examples of baud rate settings Table 18-28 and Table 18-29 show representative examples of baud rate settings. Table 18-28 Representative examples of baud rate settings (fCANMOD = 8 MHz) (1/2) Set baud rate value (unit: kbps) Division ratio of CnBRP register CnBRP register set value 1000 1 1000 CnBTR register setting value Valid bit rate setting (unit: kbps) Length of DBT SYNC SEGMENT PROP SEGMENT TSEG1 [3:0] TSEG2 [2:0] 00000000 8 1 1 3 3 0011 010 62.5 1 00000000 8 1 3 2 2 0100 001 75.0 1000 1 00000000 8 1 5 1 1 0101 000 87.5 500 1 00000000 16 1 1 7 7 0111 110 56.3 500 1 00000000 16 1 3 6 6 1000 101 62.5 500 1 00000000 16 1 5 5 5 1001 100 68.8 500 1 00000000 16 1 7 4 4 1010 011 75.0 500 1 00000000 16 1 9 3 3 1011 010 81.3 500 1 00000000 16 1 11 2 2 1100 001 87.5 500 1 00000000 16 1 13 1 1 1101 000 93.8 500 2 00000001 8 1 1 3 3 0011 010 62.5 500 2 00000001 8 1 3 2 2 0100 001 75.0 500 2 00000001 8 1 5 1 1 0101 000 87.5 250 2 00000001 16 1 1 7 7 0111 110 56.3 250 2 00000001 16 1 3 6 6 1000 101 62.5 250 2 00000001 16 1 5 5 5 1001 100 68.8 250 2 00000001 16 1 7 4 4 1010 011 75.0 250 2 00000001 16 1 9 3 3 1011 010 81.3 250 2 00000001 16 1 11 2 2 1100 001 87.5 250 2 00000001 16 1 13 1 1 1101 000 93.8 250 4 00000011 8 1 3 2 2 0100 001 75.0 250 4 00000011 8 1 5 1 1 0101 000 87.5 125 4 00000011 16 1 1 7 7 0111 110 56.3 125 4 00000011 16 1 3 6 6 1000 101 62.5 125 4 00000011 16 1 5 5 5 1001 100 68.8 125 4 00000011 16 1 7 4 4 1010 011 75.0 125 4 00000011 16 1 9 3 3 1011 010 81.3 125 4 00000011 16 1 11 2 2 1100 001 87.5 125 4 00000011 16 1 13 1 1 1101 000 93.8 125 8 00000111 8 1 3 2 2 0100 001 75.0 125 8 00000111 8 1 5 1 1 0101 000 87.5 100 4 00000011 20 1 7 6 6 1100 101 70.0 100 4 00000011 20 1 9 5 5 1101 100 75.0 100 5 00000100 16 1 7 4 4 1010 011 75.0 100 5 00000100 16 1 9 3 3 1011 010 81.3 User's Manual U18743EE1V2UM00 PHASE PHASE SEGMENT1 SEGMENT2 Sampling point (unit: %) 633 Chapter 18 CAN Controller (CAN) Table 18-28 Representative examples of baud rate settings (fCANMOD = 8 MHz) (2/2) Set baud rate value (unit: kbps) Division ratio of CnBRP register CnBRP register set value 100 8 100 CnBTR register setting value Valid bit rate setting (unit: kbps) Length of DBT SYNC SEGMENT PROP SEGMENT TSEG1 [3:0] TSEG2 [2:0] 00000111 10 1 3 3 3 0101 010 70.0 8 00000111 10 1 5 2 2 0110 001 80.0 100 10 00001001 8 1 3 2 2 0100 001 75.0 100 10 00001001 8 1 5 1 1 0101 000 87.5 83.3 4 00000011 24 1 7 8 8 1110 111 66.7 83.3 4 00000011 24 1 9 7 7 1111 110 70.8 83.3 6 00000101 16 1 5 5 5 1001 100 68.8 83.3 6 00000101 16 1 7 4 4 1010 011 75.0 83.3 6 00000101 16 1 9 3 3 1011 010 81.3 83.3 6 00000101 16 1 11 2 2 1100 001 87.5 83.3 8 00000111 12 1 5 3 3 0111 010 75.0 83.3 8 00000111 12 1 7 2 2 1000 001 83.3 83.3 12 00001011 8 1 3 2 2 0100 001 75.0 83.3 12 00001011 8 1 5 1 1 0101 000 87.5 33.3 10 00001001 24 1 7 8 8 1110 111 66.7 33.3 10 00001001 24 1 9 7 7 1111 110 70.8 33.3 12 00001011 20 1 7 6 6 1100 101 70.0 33.3 12 00001011 20 1 9 5 5 1101 100 75.0 33.3 15 00001110 16 1 7 4 4 1010 011 75.0 33.3 15 00001110 16 1 9 3 3 1011 010 81.3 33.3 16 00001111 15 1 6 4 4 1001 011 73.3 33.3 16 00001111 15 1 8 3 3 1010 010 80.0 33.3 20 00010011 12 1 5 3 3 0111 010 75.0 33.3 20 00010011 12 1 7 2 2 1000 001 83.3 33.3 24 00010111 10 1 3 3 3 0101 010 70.0 33.3 24 00010111 10 1 5 2 2 0110 001 80.0 33.3 30 00011101 8 1 3 2 2 0100 001 75.0 33.3 30 00011101 8 1 5 1 1 0101 000 87.5 Caution 634 PHASE PHASE SEGMENT1 SEGMENT2 Sampling point (unit: %) The values in Table 18-28 do not guarantee the operation of the network system. Thoroughly check the effect on the network system, taking into consideration oscillation errors and delays of the CAN bus and CAN transceiver. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Table 18-29 Chapter 18 Representative examples of baud rate settings (fCANMOD = 16 MHz) (1/2) Set baud rate value (unit: kbps) Division ratio of CnBRP register CnBRP register set value 1000 1 1000 CnBTR register setting value Valid bit rate setting (unit: kbps) Length of DBT SYNC SEGMENT PROP SEGMENT TSEG1 [3:0] TSEG2 [2:0] 00000000 16 1 1 7 7 0111 110 56.3 1 00000000 16 1 3 6 6 1000 101 62.5 1000 1 00000000 16 1 5 5 5 1001 100 68.8 1000 1 00000000 16 1 7 4 4 1010 011 75.0 1000 1 00000000 16 1 9 3 3 1011 010 81.3 1000 1 00000000 16 1 11 2 2 1100 001 87.5 1000 1 00000000 16 1 13 1 1 1101 000 93.8 1000 2 00000001 8 1 3 2 2 0100 001 75.0 1000 2 00000001 8 1 5 1 1 0101 000 87.5 500 2 00000001 16 1 1 7 7 0111 110 56.3 500 2 00000001 16 1 3 6 6 1000 101 62.5 500 2 00000001 16 1 5 5 5 1001 100 68.8 500 2 00000001 16 1 7 4 4 1010 011 75.0 500 2 00000001 16 1 9 3 3 1011 010 81.3 500 2 00000001 16 1 11 2 2 1100 001 87.5 500 2 00000001 16 1 13 1 1 1101 000 93.8 500 4 00000011 8 1 3 2 2 0100 001 75.0 500 4 00000011 8 1 5 1 1 0101 000 87.5 250 4 00000011 16 1 3 6 6 1000 101 62.5 250 4 00000011 16 1 5 5 5 1001 100 68.8 250 4 00000011 16 1 7 4 4 1010 011 75.0 250 4 00000011 16 1 9 3 3 1011 010 81.3 250 4 00000011 16 1 11 2 2 1100 001 87.5 250 8 00000111 8 1 3 2 2 0100 001 75.0 250 8 00000111 8 1 5 1 1 0101 000 87.5 125 8 00000111 16 1 3 6 6 1000 101 62.5 125 8 00000111 16 1 7 4 4 1010 011 75.0 125 8 00000111 16 1 9 3 3 1011 010 81.3 125 8 00000111 16 1 11 2 2 1100 001 87.5 125 16 00001111 8 1 3 2 2 0100 001 75.0 125 16 00001111 8 1 5 1 1 0101 000 87.5 100 8 00000111 20 1 9 5 5 1101 100 75.0 100 8 00000111 20 1 11 4 4 1110 011 80.0 100 10 00001001 16 1 7 4 4 1010 011 75.0 100 10 00001001 16 1 9 3 3 1011 010 81.3 100 16 00001111 10 1 3 3 3 0101 010 70.0 100 16 00001111 10 1 5 2 2 0110 001 80.0 100 20 00010011 8 1 3 2 2 0100 001 75.0 User's Manual U18743EE1V2UM00 PHASE PHASE SEGMENT1 SEGMENT2 Sampling point (unit: %) 635 Chapter 18 CAN Controller (CAN) Table 18-29 Representative examples of baud rate settings (fCANMOD = 16 MHz) (2/2) Set baud rate value (unit: kbps) Division ratio of CnBRP register CnBRP register set value 83.3 8 83.3 CnBTR register setting value Valid bit rate setting (unit: kbps) Length of DBT SYNC SEGMENT PROP SEGMENT TSEG1 [3:0] TSEG2 [2:0] 00000111 24 1 7 8 8 1110 111 66.7 8 00000111 24 1 9 7 7 1111 110 70.8 83.3 12 00001011 16 1 7 4 4 1010 011 75.0 83.3 12 00001011 16 1 9 3 3 1011 010 81.3 83.3 12 00001011 16 1 11 2 2 1100 001 87.5 83.3 16 00001111 12 1 5 3 3 0111 010 75.0 83.3 16 00001111 12 1 7 2 2 1000 001 83.3 83.3 24 00010111 8 1 3 2 2 0100 001 75.0 83.3 24 00010111 8 1 5 1 1 0101 000 87.5 33.3 30 00011101 24 1 7 8 8 1110 111 66.7 33.3 30 00011101 24 1 9 7 7 1111 110 70.8 33.3 24 00010111 20 1 9 5 5 1101 100 75.0 33.3 24 00010111 20 1 11 4 4 1110 011 80.0 33.3 30 00011101 16 1 7 4 4 1010 011 75.0 33.3 30 00011101 16 1 9 3 3 1011 010 81.3 33.3 32 00011111 15 1 8 3 3 1010 010 80.0 33.3 32 00011111 15 1 10 2 2 1011 001 86.7 33.3 37 00100100 13 1 6 3 3 1000 010 76.9 33.3 37 00100100 13 1 8 2 2 1001 001 84.6 33.3 40 00100111 12 1 5 3 3 0111 010 75.0 33.3 40 00100111 12 1 7 2 2 1000 001 83.3 33.3 48 00101111 10 1 3 3 3 0101 010 70.0 33.3 48 00101111 10 1 5 2 2 0110 001 80.0 33.3 60 00111011 8 1 3 2 2 0100 001 75.0 33.3 60 00111011 8 1 5 1 1 0101 000 87.5 Caution 636 PHASE PHASE SEGMENT1 SEGMENT2 Sampling point (unit: %) The values in Table 18-29 do not guarantee the operation of the network system. Thoroughly check the effect on the network system, taking into consideration oscillation errors and delays of the CAN bus and CAN transceiver. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 18.16 Operation of CAN Controller The processing procedure for showing in this chapter is recommended processing procedure to operate CAN controller. Develop the program referring to recommended processing procedure in this chapter. START Set CnGMCS register. Set CnGMCTRL register (set GOM bit = 1) Set CnBRP register, CnBTR register. Set CnIE register. Set CnMASK register. Initialize message buffers. Set CnCTRL register (set OPMODE bit). END OPMODE: Normal operation mode, normal operation mode with ABT, receive-only mode, single-shot mode, self-test mode Figure 18-35 Initialization User's Manual U18743EE1V2UM00 637 Chapter 18 CAN Controller (CAN) START Clear OPMODE No INIT mode? Yes Set CnBRP register, CnBTR register Set CnIE register Set CnMASK register Initialize message buffers CnERC and CnINFO register clear? No Yes Set CCERC bit Set CnCTRL register (Set OPMODE) END OPMODE: Normal operation mode, normal operation mode with ABT, receive-only mode, single-shot mode, self-test mode Figure 18-36 Caution 638 Re-initialization After setting the CAN module to the initialization mode, avoid setting the module to another operation mode immediately after. If it is necessary to immediately set the module to another operation mode, be sure to access registers other than the CnCTRL and CnGMCTRL registers (e.g., set a message buffer). User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 START No RDY = 1? Yes Clear RDY bit RDY = 0? No Yes Set CnMCONFm register Set CnMIDHm register, CnMIDLm register Transmit message buffer? No Yes Set CnMDLCm register Clear CnMDATAm register Set CnMCTRLm register Set RDY bit END Figure 18-37 Caution Message buffer initialization 1. Before a message buffer is initialized, the RDY bit must be cleared. 2. Make the following settings for message buffers not used by the application. * Clear the RDY, TRQ, and DN bits of the CnMCTRLm register to 0. * Clear the MA0 bit of the CnMCONFm register to 0. User's Manual U18743EE1V2UM00 639 Chapter 18 CAN Controller (CAN) Figure 18-38 shows the processing for a receive message buffer (MT[2:0] bits of CnMCONFm register = 001B to 101B). START Clear VALID bit No RDY = 1? Yes Clear RDY bit No RDY = 0? Yes RSTAT = 0 or VALID = 1? Note1 No Yes Wait for 4 CAN data bits Note2 Set message buffers Set RDY bit END Note1: Confirm that a message is being received because RDY bit must be set after a message is completely received. Note2: Avoid message buffer redefinition during store operation of message reception by waiting additional 4 CAN data bits. Figure 18-38 640 Message buffer redefinition User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 Figure 18-39 shows the processing for a transmit message buffer during transmission (MT[2:0] bits of CnMCONFm register = 000B). START Transmit abort process Clear RDY bit RDY = 0? No Yes Data frame Data frame or remote frame? Set CnMDATAxm register Set CnMDLCm register Clear RTR bit of CnMCONFm register Set CnMIDLm and CnMIDHm registers Remote frame Set CnMDLCm register Set RTR bit of CnMCONFm register Set CnMIDLm and CnMIDHm registers Set RDY bit Transmit? No Yes Wait for 1CAN data bits Set TRQ bit END Figure 18-39 Message buffer redefinition during transmission User's Manual U18743EE1V2UM00 641 Chapter 18 CAN Controller (CAN) Figure 18-40 shows the processing for a transmit message buffer (MT[2:0] bits of CnMCONFm register = 000B). START TRQ = 0? No Yes Clear RDY bit RDY = 0? No Yes Data frame Data frame or remote frame? Set CnMDATAxm register Set CnMDLCm register Clear RTR bit of CnMCONFm register Set CnMIDLm and CnMIDHm registers Remote frame Set CnMDLCm register Set RTR bit of CnMCONFm register Set CnMIDLm and CnMIDHm registers Set RDY bit Set TRQ bit END Figure 18-40 Caution Message transmit processing 1. The TRQ bit should be set after the RDY bit is set. 2. The RDY bit and TRQ bit should not be set at the same time. 642 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 Figure 18-41 shows the processing for a transmit message buffer (MT[2:0] bits of CnMCONFm register = 000B) START ABTTRG = 0? No Yes Clear RDY bit RDY = 0? No Yes Set CnMDATAxm register Set CnMDLCm register Clear RTR bit of CnMCONFm register Set CnMIDLm and CnMIDHm registers Set RDY bit Set all ABT transmit messages? No Yes TSTAT = 0? No Yes Set ABTTRG bit END Figure 18-41 Note Caution ABT message transmit processing This processing (normal operation mode with ABT) can only be applied to message buffers 0 to 7. For message buffers other than the ABT message buffers, see Figure 18-40 on page 642. The ABTTRG bit should be set to 1 after the TSTAT bit is cleared to 0. Checking the TSTAT bit and setting the ABTTRG bit to 1 must be processed consecutively. User's Manual U18743EE1V2UM00 643 Chapter 18 CAN Controller (CAN) START Transmit completion interrupt processing Read CnLOPT register Clear RDY bit RDY = 0? No Yes Data frame Data frame or remote frame? Set CnMDATAxm register Set CnMDLCm register, Clear RTR bit of CnMCONFm register. Set CnMIDLm and CnMIDHm registers Remote frame Set CnMDLCm register Set RTR bit of CnMCONFm register. Set CnMIDLm and CnMIDHm registers Set RDY bit Set TRQ bit END Figure 18-42 Caution Transmission via interrupt (using CnLOPT register) 1. The TRQ bit should be set after the RDY bit is set. 2. The RDY bit and TRQ bit should not be set at the same time. Note 644 Also check the MBON flag at the beginning and at the end of the interrupt routine, in order to check the access to the message buffers as well as TX history list registers, in case a pending sleep mode had been executed. If MBON is detected to be cleared at any check, the actions and results of the processing have to be discarded and processed again, after MBON is set again. It is recommended to cancel any sleep mode requests, before processing TX interrupts. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 START Transmit completion interrupt processing Read CnTGPT register No TOVF = 1? Yes Clear TOVF bit Clear RDY bit No RDY = 0? Yes Data frame Remote frame Data frame or remote frame? Set CnMDATAxm register Set CnMDLCm register Clear RTR bit of CnMCONFm register Set CnMIDLm and CnMIDHm registers Set CnMDLCm register Set RTR bit of CnMCONFm register Set CnMIDLm and CnMIDHm registers Set RDY bit Set TRQ bit THPM = 1? No Yes END Figure 18-43 Caution Transmission via interrupt (using CnTGPT register) 1. The TRQ bit should be set after the RDY bit is set. 2. The RDY bit and TRQ bit should not be set at the same time. Note 1. Also check the MBON flag at the beginning and at the end of the interrupt routine, in order to check the access to the message buffers as well as TX history list registers, in case a pending sleep mode had been executed. If MBON is detected to be cleared at any check, the actions and results of User's Manual U18743EE1V2UM00 645 Chapter 18 CAN Controller (CAN) the processing have to be discarded and processed again, after MBON is set again. It is recommended to cancel any sleep mode requests, before processing TX interrupts. 2. If TOVF was set once, the transmit history list is inconsistent. Consider to scan all configured transmit buffers for completed transmissions. START No CINTS0 = 1? Yes Clear CINTS0 bit Read CnTGPT register No TOVF = 1? Yes Clear TOVF bit Clear RDY bit No RDY = 0? Yes Data frame Data frame or remote frame? Set CnMDATAxm register Set CnMDLCm register Clear RTR bit of CnMCONFm register. Set CnMIDLm and CnMIDHm registers Remote frame Set CnMDLCm register Set RTR bit of CnMCONFm Set CnMIDLm and CnMIDHm registers Set RDY bit Set TRQ bit THPM = 1? No Yes END Figure 18-44 Caution Transmission via software polling 1. The TRQ bit should be set after the RDY bit is set. 2. The RDY bit and TRQ bit should not be set at the same time. 646 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Note Chapter 18 1. Also check the MBON flag at the beginning and at the end of the polling routine, in order to check the access to the message buffers as well as TX history list registers, in case a pending sleep mode had been executed. If MBON is detected to be cleared at any check, the actions and results of the processing have to be discarded and processed again, after MBON is set again. 2. If TOVF was set once, the transmit history list is inconsistent. Consider to scan all configured transmit buffers for completed transmissions. START Clear TRQ bit Wait for 11 CAN data bitsNote TSTAT = 0? No Yes Read CnLOPT register Message buffer to be aborted matches CnLOPT register? Yes Transmission successful No Transmit abort request was successful END Figure 18-45 Note Caution Transmission abort processing (except normal operation mode with ABT) There is a possibility of starting the transmission without being aborted even if TRQ bit is cleared, because the transmission request to protocol layer might already been accepted between 11 bits, total of interframe space (3 bits) and suspend transmission (8 bits). 1. Clear the TRQ bit for aborting transmission request, not the RDY bit. 2. Before making a sleep mode transition request, confirm that there is no transmission request left using this processing. 3. The TSTAT bit can be periodically checked by a user application or can be checked after the transmit completion interrupt. 4. Do not execute any new transmission request including in the other message buffers while transmission abort processing is in progress. User's Manual U18743EE1V2UM00 647 Chapter 18 CAN Controller (CAN) START Clear ABTTRG bit ABTTRG = 0? No Yes Clear TRQ bit Wait for 11 CAN data bits TSTAT = 0? No Yes Read CnLOPT register Message buffer to be aborted matches CnLOPT register? Yes Transmission successful No Transmit abort request was successful END Figure 18-46 Caution Transmission abort processing except for ABT transmission (normal operation mode with ABT) 1. Clear the TRQ bit for aborting transmission request, not the RDY bit. 2. Before making a sleep mode transition request, confirm that there is no transmission request left using this processing. 3. The TSTAT bit can be periodically checked by a user application or can be checked after the transmit completion interrupt. 4. Do not execute any new transmission request including in the other message buffers while transmission abort processing is in progress. 648 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 Figure 18-47 shows the processing to skip resumption of transmitting a message that was stopped when transmission of an ABT message buffer was aborted. START TSTAT = 0? No Yes Clear ABTTRG bit ABTTRG = 0? No Yes Clear TRQ bit of message buffer whose transmission was aborted Transmit abort Transmission start No Yes Set ABTCLR bit END Figure 18-47 Caution Transmission abort processing (normal operation mode with ABT) 1. Do not set any transmission requests while ABT transmission abort processing is in progress. 2. Make a CAN sleep mode/CAN stop mode transition request after the ABTTRG bit is cleared (after ABT mode is aborted) following the procedure shown in Figure 18-47 or Figure 18-48. When clearing a transmission request in an area other than the ABT area, follow the procedure shown in Figure 18-45 on page 647. User's Manual U18743EE1V2UM00 649 Chapter 18 CAN Controller (CAN) Figure 18-48 shows the processing to not skip resumption of transmitting a message that was stopped when transmission of an ABT message buffer was aborted. START Clear TRQ bit of message buffer undergoing transmission Clear ABTTRG bit ABTTRG = 0? No Yes Transmit abort Transmission start pointer clear? No Yes Set ABTCLR bit END Figure 18-48 Caution ABT transmission request abort processing (normal operation mode with ABT) 1. Do not set any transmission requests while ABT transmission abort processing is in progress. 2. Make a CAN sleep mode/CAN stop mode request after the ABTTRG bit is cleared (after ABT mode is stopped) following the procedure shown in Figure 18-47 or Figure 18-48. When clearing a transmission request in an area other than the ABT area, follow the procedure shown in Figure 18-45 on page 647. 650 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 START Generation of receive completion interrupt Read CnLIPT register Clear DN bit Read CnMDATAxm, CnMDLCm, CnMIDLm, and CnMIDHm registers DN = 0 AND MUC = 0 Note No Yes END Note Figure 18-49 Note Check the MUC and DN bits using one read access. Reception via interrupt (using CnLIPT register) Also check the MBON flag at the beginning and at the end of the interrupt routine, in order to check the access to the message buffers as well as reception history list registers, in case a pending sleep mode had been executed. If MBON is detected to be cleared at any check, the actions and results of the processing have to be discarded and processed again, after MBON is set again. It is recommended to cancel any sleep mode requests, before processing RX interrupts. User's Manual U18743EE1V2UM00 651 Chapter 18 CAN Controller (CAN) START Generation of receive completion interrupt Read CnRGPT register ROVF = 1? No Yes Clear ROVF bit Yes RHPM = 1? No Clear DN bit Read CnMDATAxm, CnMDLCm, CnMIDLm, CnMIDHm registers DN = 0 AND MUC = 0Note No Yes Correct data is read Illegal data is read END Note Figure 18-50 Note Check the MUC and DN bits using one read access. Reception via interrupt (using CnRGPT register) 1. Also check the MBON flag at the beginning and at the end of the interrupt routine, in order to check the access to the message buffers as well as reception history list registers, in case a pending sleep mode had been executed. If MBON is detected to be cleared at any check, the actions and results of the processing have to be discarded and processed again, after MBON is set again. It is recommended to cancel any sleep mode requests, before processing RX interrupts. 2. If ROVF was set once, the receive history list is inconsistent. Consider to scan all configured receive buffers for receptions. 652 User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 START CINTS1 = 1? No Yes Clear CINTS1 bit Read CnRGPT register ROVF = 1? No Yes Clear ROVF bit Yes RHPM = 1? No Clear DN bit Read CnMDATAxm, CnMDLCm, CnMIDLm, CnMIDHm registers DN = 0 AND MUC = 0Note No Yes Correct data is read Illegal data is read END Note Figure 18-51 Note Check the MUC and DN bits using one read access. Reception via software polling 1. Also check the MBON flag at the beginning and at the end of the polling routine, in order to check the access to the message buffers as well as reception history list registers, in case a pending sleep mode had been executed. If MBON is detected to be cleared at any check, the actions and results of the processing have to be discarded and processed again, after MBON is set again. 2. If ROVF was set once, the receive history list is inconsistent. Consider to scan all configured receive buffers for receptions. User's Manual U18743EE1V2UM00 653 Chapter 18 CAN Controller (CAN) START (when PSMODE[1:0] = 00B) Set PSMODE0 bit PSMODE0 = 1? No Yes CAN sleep mode Set PSMODE1 bit PSMODE1 = 1? No Yes Request CAN sleep mode again? Yes CAN stop mode No END Clear OPMODE INIT mode? No Yes Access to registers other than the CnCTRL and CnGMCTRL registers Set CnCTRL register (set OPMODE) ClearCINTS5 CINTS5bitbit Clear Figure 18-52 Caution 654 Setting CAN sleep mode/stop mode To abort transmission before making a request for the CAN sleep mode, perform processing according to Figure 18-45 on page 647 and Figure 18-47 on page 649. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 START CAN stop mode Clear PSMODE1 bit CAN sleep mode Releasing CAN sleep mode by CAN bus activity Releasing CAN sleep mode by user Dominant edge on CAN detected Clear PSMODE0 bit Clear PSMODE0 bit Clear CINTS5 bit END Figure 18-53 Clear CAN sleep/stop mode User's Manual U18743EE1V2UM00 655 Chapter 18 CAN Controller (CAN) START No BOFF = 1? Yes Clear all TRQ bits Note Set CnCTRL register (Clear OPMODE) Access to registers other than CnCTRL and CnGMCTRL registers Forced recovery from bus off? No Yes Set CCERC bit Set CnCTRL register (Set OPMODE) Set CnCTRL register (Set OPMODE) Wait for recovery from bus off END Note: Clear all TRQ bits when re-initialization of message buffer is executed by clearing RDY bit before bus-off recovery sequence is started. OPMODE: Normal operation mode, normal operation mode with ABT, receive-only mode, single-shot mode, self-test mode Figure 18-54 Caution 656 Bus-off recovery (except normal operation mode with ABT) When the transmission from the initialization mode to any operation modes is requested to execute bus-off recovery sequence again in the bus-off recovery sequence, reception error counter is cleared. Therefore it is necessary to detect 11 consecutive recessive-level bits 128 times on the bus again. User's Manual U18743EE1V2UM00 CAN Controller (CAN) Chapter 18 START No BOFF = 1? Yes Clear ABTTRG bit Clear all TRQ bits Note Set CnCTRL register (Clear OPMODE) Access to registers other than CnCTRL and CnGMCTRL registers Forced recovery from bus off? No Yes Set CCERC bit Set CnCTRL register (Set OPMODE) Set CnCTRL register (Set OPMODE) Wait for recovery from bus off END Note: Clear all TRQ bits when re-initialization of message buffer is executed by clearing RDY bit before bus-off recovery sequence is started. OPMODE: Normal operation mode, normal operation mode with ABT, receive-only mode, single-shot mode, self-test mode Figure 18-55 Caution Bus-off recovery (Normal Operation Mode with ABT) When the transmission from the initialization mode to any operation modes is requested to execute bus-off recovery sequence again in the bus-off recovery sequence, reception error counter is cleared. Therefore it is necessary to detect 11 consecutive recessive-level bits 128 times on the bus again. User's Manual U18743EE1V2UM00 657 Chapter 18 CAN Controller (CAN) START INIT mode Clear GOM bit GOM = 0? Yes Shutdown successful GOM = 0, EFSD = 0 END Figure 18-56 658 Normal shutdown process User's Manual U18743EE1V2UM00 No CAN Controller (CAN) Chapter 18 START Set EFSD bit Must be a subsequent write Clear GOM bit No GOM = 0? Yes Shutdown successful GOM = 0, EFSD = 0 END Figure 18-57 Caution Forced shutdown process Do not read- or write-access any registers by software between setting the EFSD bit and clearing the GOM bit. User's Manual U18743EE1V2UM00 659 Chapter 18 CAN Controller (CAN) START Error interrupt CINTS2 = 1? No Yes Check CAN module state (read CnINFO register) Clear CINTS2 bit CINTS3 = 1? No Yes Check CAN protocol error state (read CnLEC register) Clear CINTS3 bit CINTS4 = 1? Yes Clear CINTS4 bit END Figure 18-58 660 Error handling User's Manual U18743EE1V2UM00 No CAN Controller (CAN) Chapter 18 START Set PSMODE0 bit. Set PSMODE0 bit = 1 Clear PSMODE0 bit = 0 PSMODE0 bit = 1? No Clear CINTS5 bit. Clear CINTS5 bit = 1 Yes CAN sleep mode Yes No CINTS5 bit = 1? MBON bit = 0? No Yes Set CPU standby mode. END Figure 18-59 Caution Setting CPU stand-by (from CAN sleep mode) Before the CPU is set in the CPU standby mode, please check if the CAN sleep mode has been reached. However, after check of the CAN sleep mode, until the CPU is set in the CPU standby mode, the CAN sleep mode may be cancelled by wakeup from CAN bus. User's Manual U18743EE1V2UM00 661 Chapter 18 CAN Controller (CAN) START Set PSMODE0 bit. Set PSMODE0 bit = 1 Clear PSMODE0 bit = 0 PSMODE0 bit = 1? Clear CINTS5 bit. Clear CINTS5 bit = 1 No Yes CAN sleep mode Set PSMODE1 bit. Set PSMODE1 bit = 1 Clear PSMODE1 bit = 0 No PSMODE1 bit = 1? Yes CAN stop mode No MBON bit = 0? Yes Set CPU standby mode. END Figure 18-60 Caution 662 Setting CPU stand-by (from CAN stop mode) The CAN stop mode can only be released by writing 01B to the PSMODE[1:0] bit of the CnCTRL register and not by a change in the CAN bus state. User's Manual U18743EE1V2UM00 Chapter 19 A/D Converter (ADC) The V850ES/Fx3-L microcontrollers have following instances of the A/D Converter ADC: ADC V850ES/FE3-L V850ES/FF3-L V850ES/FG3-L 1 1 1 ADA0 ADA0 ADA0 10 12 16 Instances Names Channels Throughout this chapter, the individual instances of ADC are identified by "n", for example, ADAnM0 for the ADAn mode register 0. Throughout this chapter, the individual channels of each ADC instance are identified by "m", for example, ADAnCRm for the conversion result register m of ADAn. 19.1 Functions The A/D Converter converts analog input signals into digital values. The A/D Converter has the following features. * 10-bit resolution * Successive approximation method * The following functions are provided as operation modes. - Continuous select mode - Continuous scan mode - One-shot select mode - One-shot scan mode * The following functions are provided as trigger modes. - Software trigger mode - Timer trigger mode - Hardware trigger mode - External trigger mode * Power-fail monitor function (conversion result compare function) * Self diagnostic function * Discharge function User's Manual U18743EE1V2UM00 663 Chapter 19 A/D Converter (ADC) The block diagram of the A/D Converter is shown below. AVREF0 ADAnPS bit { Selector ADC0 Ta p selector Sample & hold circuit ANI0 ANI1 ANIm ADAnCE bit AVSS Voltage comparator SAR INTAD fXP1 INTTAA2CC0 INTTAA2CC1 TQTADT0 ADTRG ADAnCR0 Controller ADAnCR1 Edge detection Voltage comperator ADAnETS0 bit ADAnETS1 bit ADAnCRm ADAnM0 ADAnM1 ADAnM2 ADAnS Internal bus Figure 19-1 664 ADAnPFE bit ADAnPFC bit Control Circuit Block diagram of A/D Converter User's Manual U18743EE1V2UM00 ADAnPFT ADAnPFM A/D Converter (ADC) Chapter 19 19.2 Configuration The A/D Converter includes the following hardware. Table 19-1 Configuration of A/D Converter Item Configuration Analog inputs ANI0 to ANIm Registers Successive approximation register (SAR) A/D conversion result registers ADAnCRm, ADAnCRmH AVREF A/D conversion diagnostic registers ADAnCRDD, ADAnCRDDH AVSS A/D conversion diagnostic registers ADAnCRSS, ADAnCRSSH ADC power-fail compare mode register ADAnPFM ADC power-fail compare threshold value register ADAnPFT Control registers A/D Converter mode registers 0 to 2 (ADAnM0 to ADAnM2) A/D Converter channel specification register 0 (ADAnS) (1) SAR - Successive approximation register The SAR register compares the voltage value of the analog input signal with the voltage tap (compare voltage) value from the series resistor string, and holds the comparison result starting from the most significant bit (MSB). When the comparison result has been held down to the least significant bit (LSB) (i.e., when A/D conversion is complete), the contents of the SAR register are transferred to the ADAnCRm register. (2) A/D conversion result register n (ADAnCRm), A/D conversion result register nH (ADAnCRmH) The ADAnCRm register is a 16-bit register that stores the A/D conversion result. ADAnCRm consist of m registers and the A/D conversion result is stored in the 10 higher bits of the ADAnCRm register corresponding to analog input. (The lower 6 bits are fixed to 0.) The ADAnCRm register is read-only, in 16-bit units. When using only the higher 8 bits of the A/D conversion result, the ADAnCRmH register is read-only, in 8-bit units. Caution (3) A write operation to the ADAnM0 and ADAnS registers may cause the contents of the ADAnCRm register to become undefined. After the conversion, read the conversion result before writing to the ADAnM0 and ADAnS registers. Correct conversion results may not be read if a sequence other than the above is used. Power-fail compare threshold value register (ADAnPFT) The ADAnPFT register sets a threshold value that is compared with the value of A/D conversion result register nH (ADAnCRmH). The 8-bit data set to the ADAnPFT register is compared with the higher 8 bits of the A/D conversion result register (ADAnCRmH). This register can be read or written in 8-bit or 1-bit units. Reset input clears this register to 00H. User's Manual U18743EE1V2UM00 665 Chapter 19 A/D Converter (ADC) (4) Sample & hold circuit The sample & hold circuit samples each of the analog input signals selected by the input circuit and sends the sampled data to the Voltage Comparator. This circuit also holds the sampled analog input signal voltage during A/D conversion. (5) Voltage comparator The Voltage comparator compares a voltage value that has been sampled and held with the voltage value of the series resistor string. (6) Series resistor string This series resistor string is connected between AVREF and AVSS and generates a voltage for comparison with the analog input signal. (7) ANInm pins These are analog input pins for the m A/D Converter channels and are used to input analog signals to be converted into digital signals. Pins other than the one selected as the analog input by the ADAnS register can be used as input port pins. Caution 1. Make sure that the voltages input to the ANInm pins do not exceed the rated values. In particular if a voltage of AVREF or higher is input to a channel, the conversion value of that channel becomes undefined, and the conversion values of the other channels may also be affected. 2. The analog input pins ANInm function also as input port pins. If any of ANInmm is selected and A/D converted, do not execute an input instruction to this ports during conversion. If executed, the conversion resolution may be degraded. (8) AVREF pin This is the pin used to input the reference voltage of the A/D Converter. AVREF also delivers the A/D Converter's analog supply voltage AVDD. AVREF has to be connected to VDD even if the A/D Converter is not used. The signals input to the ANInmm pins are converted to digital signals based on the voltage applied between the AVREF and AVSS pins. (9) AVSS pin This is the ground pin of the A/D Converter. Always make the potential at this pin the same as that at the VSS pin even when the A/D Converter is not used. 666 User's Manual U18743EE1V2UM00 A/D Converter (ADC) Chapter 19 19.3 ADC Registers The A/D Converter is controlled by the following registers: * A/D Converter mode registers 0, 1, 2 (ADAnM0, ADAnM1, ADAnM2) * A/D Converter channel specification register 0 (ADAnS) * Power-fail compare mode register (ADAnPFM) The following registers are also used: * A/D conversion result register n (ADAnCRm) * A/D conversion result register nH (ADAnCRmH) * Power-fail compare threshold value register (ADAnPFT) (1) ADAnM0 - ADC mode register 0 The ADAnM0 register is an 8-bit register that specifies the operation mode and controls conversion operations. This register can be read or written in 8-bit or 1-bit units. However, bit 0 is readonly. Reset input clears this register to 00H. After reset: 00H ADAnM0 R/W Address: ADA0M0 FFFFF200H 7 6 5 4 3 2 1 0 ADAnCE ADAnPS ADAnMD1 ADAnMD0 ADAnETS1 ADAnETS0 ADAnTMD ADAnEF ADAnCE A/D conversion control 0 Stops conversion 1 Starts conversion ADAnPS A/D conversion control 0 A/D power OFF 1 A/D power ON Note: The A/D Converter needs a stabilization time after A/D power on. Only if the specified stabilization time after ADAnPS = 1 (power on) is taken, the first conversion result is valid. ADAnMD1 ADAnMD0 Specification of A/D conversion operation mode 0 0 Continuous select mode 0 1 Continuous scan mode 1 0 One-shot select mode 1 1 One-shot scan mode User's Manual U18743EE1V2UM00 667 Chapter 19 A/D Converter (ADC) Caution ADAnETS1 ADAnETS0 Specification of external trigger (ADTRG pin) input valid edge 0 0 No edge detection 0 1 Falling edge detection 1 0 Rising edge detection 1 1 Detection of both rising and falling edges ADAnTMD Trigger mode specification 0 Software trigger mode 1 External trigger mode/ timer trigger mode ADAnEF A/D Converter status display 0 A/D conversion stopped 1 A/D conversion in progress 1. Writing to ADAnEF is ignored. 2. When not using the A/D Converter, stop the operation by setting the ADAnPS bit to 0 to reduce the current consumption. 3. During A/D conversion (ADAnCE bit = 1), the ADAnFR3 to ADAnFR0 bits of the ADAnM1 register cannot be changed. 4. Access to the ADAnM0 register during sub-clock operation and when the main clock is stopped is prohibited. 668 User's Manual U18743EE1V2UM00 A/D Converter (ADC) (2) Chapter 19 ADAnM1 - ADC mode register 1 The ADAnM1 register is an 8-bit register that controls the conversion time specification. This register can be read or written in 8-bit or 1-bit units. Reset input clears this bit to 00H. After reset: 00H ADAnM1 R/W Address: ADA0M1 FFFFF201H 7 6 5 4 3 2 1 0 0 0 0 0 ADAnFR3 ADAnFR2 ADAnFR1 ADAnFR0 Caution 1. Be sure to clear bits 4-7 to 0. 2. Changing the ADAnFR3 to ADAnFR0 bits of the ADAnM1 register during conversion (ADAnCE0 bit = 1) is prohibited. For A/D conversion time settings, see Table 19-2. Table 19-2 Conversion, sampling, discharge time settings ADAnFR3-0 Table 19-3 ADAnDISC=1 (Discharge function) A/D sampling time 3 2 1 0 A/D conversion time 0 0 0 0 32/fXP1 4/fXP1 17/fXP1 0 0 0 1 64/fXP1 8/fXP1 34/fXP1 0 0 1 0 96/fXP1 12/fXP1 51/fXP1 0 0 1 1 128/fXP1 16/fXP1 68/fXP1 0 1 0 0 160/fXP1 20/fXP1 85/fXP1 0 1 0 1 192/fXP1 24/fXP1 102/fXP1 0 1 1 0 224/fXP1 28/fXP1 119/fXP1 0 1 1 1 256/fXP1 32/fXP1 136/fXP1 1 0 0 0 288/fXP1 36/fXP1 153/fXP1 1 0 0 1 320/fXP1 40/fXP1 170/fXP1 1 0 1 0 prohibited prohibited prohibited 1 0 1 1 prohibited prohibited prohibited 1 1 0 0 prohibited prohibited prohibited 1 1 0 1 prohibited prohibited prohibited 1 1 1 0 prohibited prohibited prohibited 1 1 1 1 prohibited prohibited prohibited Conversion time settings (1/2) ADAnFR3-0 3 2 1 0 A/D conversio n time 0 0 0 0 32/fXP1 User's Manual U18743EE1V2UM00 fXP1 = 20 MHz fXP1 = 16 MHz fXP1 = 10 MHz fXP1 = 4 MHz prohibited prohibited 3.20 s 8.00 s 669 Chapter 19 Table 19-3 670 A/D Converter (ADC) Conversion time settings (2/2) 0 0 0 1 64/fXP1 3.20 s 4.00 s 6.40 s 16.00 s 0 0 1 0 96/fXP1 4.80 s 6.00 s 9.60 s prohibited 0 0 1 1 128/fXP1 6.40 s 8.00 s 12.80 s prohibited 0 1 0 0 160/fXP1 8.00 s 10.00 s 16.00 s prohibited 0 1 0 1 192/fXP1 9.60 s 12.00 s prohibited prohibited 0 1 1 0 224/fXP1 11.20 s 14.00 s prohibited prohibited 0 1 1 1 256/fXP1 12.80 s 16.00 s prohibited prohibited 1 0 0 0 288/fXP1 14.40 s prohibited prohibited prohibited 1 0 0 1 320/fXP1 16.00 s prohibited prohibited prohibited 1 0 1 0 352/fXP1 prohibited prohibited prohibited prohibited 1 0 1 1 384/fXP1 prohibited prohibited prohibited prohibited 1 1 0 0 416/fXP1 prohibited prohibited prohibited prohibited 1 1 0 1 448/fXP1 prohibited prohibited prohibited prohibited 1 1 1 0 480/fXP1 prohibited prohibited prohibited prohibited 1 1 1 1 512/fXP1 prohibited prohibited prohibited prohibited User's Manual U18743EE1V2UM00 A/D Converter (ADC) (3) Chapter 19 ADAnM2 - ADC mode register 2 The ADAnM2 register specifies the hardware trigger mode. This register can be read or written in 8-bit or 1-bit units. Reset input clears this register to 00H. After reset: 00H ADAnM2 R/W Address: 7 6 0 0 Note 5 4 ADAnDIAG ADAnDISC 3 2 0 0 1 0 ADAnTMD1 ADAnTMD0 ADAnDIAG Diagnostic function enable 0 Diagnostic function disabled 1 Diagnostic function enabled ADAnDISC Discharge function enable 0 Discharge function disabled 1 Discharge function enabled In the discharge function the AVREFM (ASS) voltage is sampled during 4 clocks (fXP1) after finishing A/D conversion. Therefore, additional 2 clocks must be added to the A/D conversion time. ADAnTMD1 Caution AD0M2 FFFFF203H ADAnTMD0 Specification of trigger mode 0 0 ADTRG external trigger mode 0 1 INTTAA2CC0 timer trigger mode 0 1 0 INTTAA2CC1 timer trigger mode 1 1 1 prohibited Be sure to clear bits 7, 6, 3, and 2 to 0. User's Manual U18743EE1V2UM00 671 Chapter 19 A/D Converter (ADC) (4) ADAnS - ADC channel specification register The ADAnS register specifies the pin that inputs the analog voltage to be converted into a digital signal. This register can be read or written in 8-bit or 1-bit units. Reset input clears this register to 00H. After reset: 00H ADAnS R/W Address: ADA0S FFFFF202H 7 6 5 4 3 2 1 0 0 0 0 ADAnS4 ADAnS3 ADAnS2 ADAnS1 ADAnS0 Analog input to convert ADAnS[4:0] ADAnDIAG = 0 (without diagnostic function) ADAnDIAG = 1 (with diagnostic function) 4 3 2 1 0 Select mode Scan mode Select mode 0 0 0 0 0 ANI0 ANI100 ANI0 ANI100 AVREF ANI0 ANI100 - AVREF - AVSS 0 0 0 0 1 ANI1 ANI101 ANI0, ANI1 ANI100, ANI101 AVSS ANI0, ANI1 ANI100, ANI101 - AVREF - AVSS 0 0 0 1 0 ANI2 ANI102 ANI0 to ANI2 ANI100, ANI102 prohibited ANI0 to ANI2 ANI100, ANI102 - AVREF - AVSS 0 0 0 1 1 ANI3 ANI103 ANI0 to ANI3 ANI100, ANI103 prohibited ANI0 to ANI3 ANI100, ANI103 - AVREF - AVSS 0 0 1 0 0 ANI4 ANI104 ANI0 to ANI4 ANI100, ANI104 prohibited ANI0 to ANI4 ANI100, ANI104 - AVREF - AVSS 0 0 1 0 1 ANI5 ANI105 ANI0 to ANI5 ANI100, ANI105 prohibited ANI0 to ANI5 ANI100, ANI105 - AVREF - AVSS 0 0 1 1 0 ANI6 ANI106 ANI0 to ANI6 ANI100, ANI106 prohibited ANI0 to ANI6 ANI100, ANI106 - AVREF - AVSS 0 0 1 1 1 ANI7 ANI107 ANI0 to ANI7 ANI100, ANI107 prohibited ANI0 to ANI7 ANI100, ANI107 - AVREF - AVSS 0 1 0 0 0 ANI8 ANI108 ANI0 to ANI8 ANI100, ANI108 prohibited ANI0 to ANI8 ANI100, ANI108 - AVREF - AVSS 0 1 0 0 1 ANI9 ANI109 ANI0 to ANI9 ANI100, ANI109 prohibited ANI0 to ANI9 ANI100, ANI109 - AVREF - AVSS 0 1 0 1 0 ANI10 ANI110 ANI0 to ANI10 ANI100, ANI110 prohibited ANI0 to ANI10 ANI100, ANI110 - AVREF - AVSS 0 1 0 1 1 ANI11 ANI111 ANI0 to ANI11 ANI100, ANI111 prohibited ANI0 to ANI11 ANI100, ANI111 - AVREF - AVSS 0 1 1 0 0 ANI12 ANI112 ANI0 to ANI12 ANI100, ANI112 prohibited ANI0 to ANI12 ANI100, ANI112 - AVREF - AVSS 0 1 1 0 1 ANI13 ANI113 ANI0 to ANI13 ANI100, ANI113 prohibited ANI0 to ANI13 ANI100, ANI113 - AVREF - AVSS 0 1 1 1 0 ANI14 ANI114 ANI0 to ANI14 ANI100, ANI114 prohibited ANI0 to ANI14 ANI100, ANI114 - AVREF - AVSS 0 1 1 1 1 ANI15 ANI115 ANI0 to ANI15 ANI100, ANI115 prohibited ANI0 to ANI15 ANI100, ANI115 - AVREF - AVSS 672 User's Manual U18743EE1V2UM00 Scan mode A/D Converter (ADC) Chapter 19 Analog input to convert ADAnS[4:0] ADAnDIAG = 0 (without diagnostic function) ADAnDIAG = 1 (with diagnostic function) 4 3 2 1 0 Select mode Scan mode Select mode 1 0 0 0 0 ANI16 ANI0 to ANI16 prohibited ANI0 to ANI16 - AVREF - AVSS 1 0 0 0 1 ANI17 ANI0 to ANI17 prohibited ANI0 to ANI17 - AVREF - AVSS 1 0 0 1 0 ANI18 ANI0 to ANI18 prohibited ANI0 to ANI18 - AVREF - AVSS 1 0 0 1 1 ANI19 ANI0 to ANI19 prohibited ANI0 to ANI19 - AVREF - AVSS 1 0 1 0 0 ANI20 ANI0 to ANI20 prohibited ANI0 to ANI20 - AVREF - AVSS 1 0 1 0 1 ANI21 ANI0 to ANI21 prohibited ANI0 to ANI21 - AVREF - AVSS 1 0 1 1 0 ANI22 ANI0 to ANI22 prohibited ANI0 to ANI22 - AVREF - AVSS 1 0 1 1 1 ANI23 ANI0 to ANI23 prohibited ANI0 to ANI23 - AVREF - AVSS Other than above a) Scan mode Setting prohibiteda When the channel in which an analog input does not exist is set, a conversion result becomes undefined. User's Manual U18743EE1V2UM00 673 Chapter 19 A/D Converter (ADC) (5) ADAnCRm, ADAnCRmH - ADC conversion result registers The ADAnCRm and ADAnCRmH registers store the A/D conversion results. These registers are read-only, in 16-bit or 8-bit units. However, specify the ADAnCRm register for 16-bit access and the ADAnCRmH register for 8-bit access. The 10 bits of the conversion result are read from the higher 10 bits of the ADAnCRm register, and 0 is read from the lower 6 bits. The higher 8 bits of the conversion result are read from the ADAnCRmH register. After reset: undefined ADAnCRm ADA0CR0 ADA0CR2 ADA0CR4 ADA0CR6 ADA0CR8 ADA0CR10 ADA0CR12 ADA0CR14 ADA0CR16 ADA0CR18 ADA0CR20 ADA0CR22 FFFFF210H, FFFFF214H, FFFFF218H, FFFFF21CH, FFFFF220H, FFFFF224H, FFFFF228H, FFFFF22CH, FFFFF230H, FFFFF234H, FFFFF238H, FFFFF23CH, ADA0CR1 ADA0CR3 ADA0CR5 ADA0CR7 ADA0CR9 ADA0CR11 ADA0CR13 ADA0CR15 ADA0CR17 ADA0CR19 ADA0CR21 ADA0CR23 FFFFF212H, FFFFF216H, FFFFF21AH, FFFFF21EH, FFFFF222H, FFFFF226H, FFFFF22AH, FFFFF22EH, FFFFF232H, FFFFF236H, FFFFF23AH, FFFFF23EH 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 0 0 0 0 0 0 R Address: ADA0CR0H FFFFF211H, ADA0CR2H FFFFF215H, ADA0CR4H FFFFF219H, ADA0CR6H FFFFF21DH, ADA0CR8H FFFFF221H, ADA0CR10H FFFFF225H, ADA0CR12H FFFFF229H, ADA0CR14H FFFFF22DH, ADA0CR16H FFFFF231H, ADA0CR18H FFFFF235H, ADA0CR20H FFFFF239H, ADA0CR22H FFFFF23DH, ADA0CR1H FFFFF213H, ADA0CR3H FFFFF217H, ADA0CR5H FFFFF21BH, ADA0CR7H FFFFF21FH, ADA0CR9H FFFFF223H, ADA0CR11H FFFFF227H, ADA0CR13H FFFFF22BH, ADA0CR15H FFFFF22FH, ADA0CR17H FFFFF233H, ADA0CR19H FFFFF237H, ADA0CR21H FFFFF23BH, ADA0CR23H FFFFF23FH 7 6 5 4 3 2 1 0 AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 Caution 674 Address: 15 After reset: undefined ADAnCRmH R When writing to the ADAnM0-ADAnM2, ADAnS, ADAnPFM and the ADAnPFT register the contents of the ADAnCRm registers might become undefined. Therefore, after the conversion operation ends read the conversion result before writing to any of the above registers. Moreover, when external/timer trigger is used, the content of the ADAnCRm register must be read before the following external/timer trigger is accepted. User's Manual U18743EE1V2UM00 A/D Converter (ADC) Chapter 19 The relationship between the analog voltage input to the analog input pins ANInmm and the A/D conversion result (of A/D conversion result register n ADAnCRm is as follows: V IN ADnCRm = INT(------------------ * 1024 + 0,5) AV REF or AV REF AV REF ( ADAnCRm - 0,5 ) * ------------------ V IN < ( ADAnCRm + 0,5 ) * -----------------1024 1024 INT( ): Function that returns the integer of the value in ( ) VIN: Analog input voltage at AINn pin AVREF: AVREF0 pin voltage ADAnCRm: Value of A/D conversion result register n (ADAnCRm) Figure 19-2 shows the relationship between the analog input voltage and the A/D conversion results. ADAnCRm SAR 1,023 FFC0H 1,022 FF80H A/D conversion result 1,021 FF40H 3 00C0H 2 0080H 1 0040H 0 0000H 1 1 3 2 5 3 2,048 1,024 2,048 1,024 2,048 1,024 2,043 1,022 2,045 1,023 2,047 1 2,048 1,024 2,048 1,024 2,048 Input voltage/AVREF Figure 19-2 Relationship between analog input voltage and A/D conversion results User's Manual U18743EE1V2UM00 675 Chapter 19 A/D Converter (ADC) (6) ADAnCRDD, ADAnCRDDH - AVREF A/D conversion diagnostic registers The ADAnCRDD and ADAnCRDDH registers store the result of the AVREF conversion if the ADC diagnostic function is enabled (ADAnM2.ADAnDIAG = 1). These registers are read-only, in 16-bit or 8-bit units. However, specify the ADAnCRDD register for 16-bit access and the ADAnCRDDH register for 8-bit access. The 10 bits of the conversion result are read from the higher 10 bits of the ADAnCRDD register, and 0 is read from the lower 6 bits. The higher 8 bits of the conversion result are read from the ADAnCRDDH register. After reset: 00H ADAnCRDD R 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 0 0 0 0 0 0 R Address: ADA0CRDDH FFFFF20CH ADA1CRDDH FFFFF24DH 7 6 5 4 3 2 1 0 AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 Caution 676 ADA0CRDD FFFFF20CH 15 After reset: 00H ADAnCRDDH Address: Since A/D conversion accuracy is influenced of use conditions, the result does not necessarily become all 1 (ADAnCRDD = FFC0H) when converting AVREF. User's Manual U18743EE1V2UM00 A/D Converter (ADC) (7) Chapter 19 ADAnCRSS, ADAnCRSSH - AVSS A/D conversion diagnostic registers The ADAnCRSS and ADAnCRSSH registers store the result of the AVSS conversion if the ADC diagnostic function is enabled (ADAnM2.ADAnDIAG = 1). These registers are read-only, in 16-bit or 8-bit units. However, specify the ADAnCRSS register for 16-bit access and the ADAnCRSSH register for 8-bit access. The 10 bits of the conversion result are read from the higher 10 bits of the ADAnCRSS register, and 0 is read from the lower 6 bits. The higher 8 bits of the conversion result are read from the ADAnCRSSH register. After reset: FFFFH ADAnCRSS R ADA0CRSS FFFFF20EH 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 1 1 1 1 1 1 After reset: FFH ADAnCRSSH Address: R Address: ADA0CRSSH FFFFF20FH 7 6 5 4 3 2 1 0 AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 Caution Since A/D conversion accuracy is influenced of use conditions, the result does not necessarily become all 0 (ADAnCRSS = 003FH) when converting AVSS. User's Manual U18743EE1V2UM00 677 Chapter 19 A/D Converter (ADC) (8) ADAnPFM - ADC power-fail compare mode register The ADAnPFM register is an 8-bit register that sets the power-fail compare mode. This register can be read or written in 8-bit or 1-bit units. Reset input clears this register to 00H. After reset: 00H R/W ADAnPFM Address: ADA0PFM FFFFF204H 7 6 5 4 3 2 1 0 ADAnPFE ADAnPFC0 0 0 0 0 0 0 Caution ADAnPFE Power-fail compare enable/disable 0 Power-fail compare disabled 1 Power-fail compare enabled ADAnPFC Power-fail compare mode 0 Generates interrupt request INTAD if ADAnCRmH ADAnPFT 1 Generates interrupt request INTAD if ADAnCRmH < ADAnPFT 1. In the select mode, the 8-bit data set to the ADAnPFT register is compared with the value of the ADAnCRmH register specified by the ADAnS register. If the result matches the condition specified by the ADAnPFC bit, the conversion result is stored in the ADAnCRm register and the INTAD signal is generated. If it does not match, however, the interrupt signal is not generated. 2. In the scan mode, the 8-bit data set to the ADAnPFT register is compared with the contents of the ADAnCR0H register. If the result matches the condition specified by the ADAnPFC bit, the conversion result is stored in the ADAnCR0 register and the INTAD signal is generated. If it does not match, however, the INTAD signal is not generated. Regardless of the comparison result, the scan operation is continued and the conversion result is stored in the ADAnCRm register until the scan operation is completed. However, the INTAD signal is not generated after the scan operation has been completed. 678 User's Manual U18743EE1V2UM00 A/D Converter (ADC) (9) Chapter 19 ADAnPFT - ADC power-fail compare threshold value register The ADAnPFT register sets the compare value in the power-fail compare mode. This register can be read or written in 8-bit or 1-bit units. Reset input clears this register to 00H. After reset: 00H ADAnPFT R/W Address: ADA0PFT FFFFF205H 7 6 5 4 3 2 1 0 ADAnPFT7 ADAnPFT6 ADAnPFT5 ADAnPFT4 ADAnPFT3 ADAnPFT2 ADAnPFT1 ADAnPFT0 User's Manual U18743EE1V2UM00 679 Chapter 19 A/D Converter (ADC) 19.4 Operation 19.4.1 Basic operation 1. Set the operation mode, trigger mode, and conversion time for executing A/D conversion by using the ADAnM0, ADAnM1, ADAnM2, and ADAnS registers. Set the ADAnPS bit of the ADAnM0 register to supply power to the analog circuitry of the ADC. Do not enable AD conversion before the ADC stabilization time is elapsed. For the stabilization time refer to the Electrical Target Specification. When the ADAnCE bit of the ADAnM0 register is set, conversion is started in the software trigger mode and the A/D Converter waits for a trigger in the external or timer trigger mode. 2. When A/D conversion is started, the voltage input to the selected analog input channel is sampled by the sample & hold circuit. 3. When the sample & hold circuit samples the input channel for a specific time, it enters the hold status, and holds the input analog voltage until A/D conversion is complete. 4. Set bit 9 of the successive approximation register (SAR). The tap selector selects (1/2) AVREF as the voltage tap of the series resistor string. 5. The voltage difference between the voltage of the series resistor string and the analog input voltage is compared by the Voltage Comparator. If the analog input voltage is higher than (1/2) AVREF, the MSB of the SAR register remains set. If it is lower than (1/2) AVREF, the MSB is reset. 6. Next, bit 8 of the SAR register is automatically set and the next comparison is started. Depending on the value of bit 9, to which a result has been already set, the voltage tap of the series resistor string is selected as follows: -Bit 9 = 1: (3/4) AVREF -Bit 9 = 0: (1/4) AVREF This voltage tap and the analog input voltage are compared and, depending on the result, bit 8 is manipulated as follows. Analog input voltage Voltage tap: Bit 8 = 1 Analog input voltage Voltage tap: Bit 8 = 0 7. This comparison is continued to bit 0 of the SAR register. 8. When comparison of the 10 bits is complete, the valid digital result is stored in the SAR register, which is then transferred to and stored in the ADAnCRm register. At the same time, an A/D conversion end interrupt request signal (INTAD) is generated. 680 User's Manual U18743EE1V2UM00 A/D Converter (ADC) Chapter 19 Conversion time Sampling time A/D converter operation SAR Sampling A/D conversion Undefined Conversion result Conversion result ADAnCRm INTAD INTAD1 Figure 19-3 A/D Converter basic operation 19.4.2 Trigger mode The timing of starting the conversion operation is specified by setting a trigger mode. The trigger mode includes a software trigger mode and hardware trigger modes. The hardware trigger modes include timer trigger modes 0 and 1, and external trigger mode. The ADAnTMD bit of the ADAnM0 register is used to set the trigger mode. In timer trigger mode set ADAnM2.ADAnTMD[1:0] = 01. (1) Software trigger mode When the ADAnCE bit of the ADAnM0 register is set to 1, the signal of the analog input pin ANInmm specified by the ADAnS register is converted. When conversion is complete, the result is stored in the ADAnCRm register. At the same time, the A/D conversion end interrupt request signal (INTAD) is generated. If the operation mode specified by the ADAnMD1 and ADAnMD0 bits of the ADAnM0 register is the continuous select/scan mode, the next conversion is started, unless the ADAnCE bit is cleared to 0 after completion of the first conversion. When conversion is started, the ADAnEF bit is set to 1 (indicating that conversion is in progress). If the ADAnM0, ADAnM2, ADAnS, ADAnPFM, or ADAnPFT register is written during conversion, the conversion is aborted and started again from the beginning. User's Manual U18743EE1V2UM00 681 Chapter 19 A/D Converter (ADC) (2) External trigger mode In this mode, converting the signal of the analog input pin (ANI0 to ANI23) specified by the ADAnS register is started when an external trigger is input (to the ADTRG pin). Which edge of the external trigger is to be detected (i.e., the rising edge, falling edge, or both rising and falling edges) can be specified by using the ADAnETS1 and ADAnETS0 bits of the ADAnM0 register. When the ADAnCE bit of the ADAnM0 register set to 1, the A/D Converter waits for the trigger, and starts conversion after the external trigger has been input. When conversion is completed, the result of conversion is stored in the ADAnCRm register. At the same time, the A/D conversion end interrupt request signal (INTAD) is generated, and the A/D Converter waits for the trigger again. When conversion is started, the ADAnEF bit is set to 1 (indicating that conversion is in progress). While the A/D Converter is waiting for the trigger, however, the ADAnEF bit is cleared to 0 (indicating that conversion is stopped). If the valid trigger is input during the conversion operation, the conversion is aborted and started again from the beginning. If the ADAnM0, ADAnM2, ADAnS, ADAnPFM, or ADAnPFT register is written during the conversion operation, the conversion is not aborted, and the A/D Converter waits for the trigger again. (3) Timer trigger mode In this mode, converting the signal of the analog input pin ANInmm, specified by the ADAnS register, is started by any of the timer output signals INTTAA2CC0 or INTTAA2CC1. The timer output signal is selected by the ADAnTMD1 and ADAnTMD0 bits of the ADAnM2 register, and conversion is started at the rising edge of the timer output signal. When the ADAnCE bit of the ADAnM0 register is set to 1, the A/D Converter waits for a trigger, and starts conversion when the rising edge of the timer output signal is input. When conversion is completed, the result of the conversion is stored in the ADAnCRm register. At the same time, the A/D conversion end interrupt request signal (INTAD) is generated, and the A/D Converter waits for the trigger again. When conversion is started, the ADAnEF bit is set to 1 (indicating that conversion is in progress). While the A/D Converter is waiting for the trigger, however, the ADAnEF bit is cleared to 0 (indicating that conversion is stopped). If the valid trigger is input during the conversion operation, the conversion is aborted and started again from the beginning. If the ADAnM0, ADAnM2, ADAnS, ADAnPFM, or ADAnPFT register is written during conversion, the conversion is stopped and the A/D Converter waits for the trigger again. 682 User's Manual U18743EE1V2UM00 A/D Converter (ADC) Chapter 19 19.4.3 Operation modes Four operation modes are available as the modes in which to set the ANInmm pins: continuous select mode, continuous scan mode, one-shot select mode and one-shot scan mode.. The operation mode is selected by the ADAnMD1 and ADAnMD0 bits of the ADAnM0 register. (1) Continuous select mode In this mode, the voltage of one analog input pin selected by the ADAnS register is continuously converted into a digital value. The conversion result is stored in the ADAnCRm register corresponding to the analog input pin. In this mode, an analog input pin corresponds to an ADAnCRm register on a one-to-one basis. Each time A/D conversion is completed, the A/D conversion end interrupt request signal (INTAD) is generated. After completion of conversion, the next conversion is started, unless the ADAnCE bit of the ADAnM0 register is cleared to 0. ANI1 Data 2 Data 3 Data 4 Data 5 Data 3 (ANI1) Data 4 (ANI1) Data 5 (ANI1) Data 6 Data 1 Data 1 (ANI1) A/D conversion Data 2 (ANI1) Data 1 (ANI1) ADA0CR1 Data 2 (ANI1) Data 3 (ANI1) Data 4 (ANI1) Data 6 (ANI1) Data 5 (ANI1) Data 6 (ANI1) INTAD INTAD1 Conversion start set ADA0M0.ADA0CE = 1 Figure 19-4 (2) Timing example of continuous select mode operation (ADA0S = 01H) Continuous scan mode In this mode, analog input pins are sequentially selected, from the ANI0 pin to the pin specified by the ADAnS register, and their values are converted into digital values. The result of each conversion is stored in the ADAnCRm register corresponding to the analog input pin. When conversion of the analog input pin specified by the ADAnS register is complete, the A/D conversion end interrupt request signal (INTAD) is generated, and A/D conversion is started again from the ANI0 pin, unless the ADAnCE bit of the ADAnM0 register is cleared to 0. User's Manual U18743EE1V2UM00 683 Chapter 19 A/D Converter (ADC) (a) Timing example ANI0 Data 1 Data 5 ANI1 Data 6 Data 2 Data 7 Data 3 ANI2 ANI3 Data 4 Data 1 (ANI0) A/D conversion Data 2 (ANI1) Data 1 (ANI0) ADA0CRn Data 3 (ANI2) Data 2 (ANI1) Data 4 (ANI3) Data 3 (ANI2) Data 5 (ANI0) Data 4 (ANI3) Data 6 (ANI1) Data 5 (ANI0) Data 7 (ANI2) Data 6 (ANI1) INTAD Conversion start Set ADA0CE bit = 1 (b) Block diagram Analog input pin ADA0CRn registers ANI0 ADA0CR0 ANI1 ADA0CR1 ADA0CR2 ANI2 ANI3 A/D converter ANI4 ADA0CR4 ANI5 ADA0CR5 . . . . ANIm Figure 19-5 684 ADA0CR3 . . . ADA0CRm Timing example of continuous scan mode operation (ADA0S register = 03H) User's Manual U18743EE1V2UM00 A/D Converter (ADC) (3) Chapter 19 One-shot select mode In this mode, the voltage on the analog input pin specified by the ADA0S register is converted into a digital value only once. The conversion result is stored in the ADA0CRn register corresponding to the analog input pin. In this mode, an analog input pin and an ADA0CRn register correspond on a one-to-one basis. When A/D conversion has been completed once, the INTAD signal is generated. The A/D conversion operation is stopped after it has been completed. Figure 19-6 Timing example of one-shot select mode operation (ADA0S Register = 01H) User's Manual U18743EE1V2UM00 685 Chapter 19 A/D Converter (ADC) (4) One-shot scan mode In this mode, analog input pins are sequentially selected, from the ANI0 pin to the pin specified by the ADAnS register, and their values are converted into digital values. The result of each conversion is stored in the ADAnCRm register corresponding to the analog input pin. When conversion of the analog input pin specified by the ADAnS register is complete, the A/D conversion end interrupt request signal (INTAD) is generated, and A/D conversion is stopped.(n = 0-23). (a) Timing example ANI0 Data 1 Data 5 ANI1 Data 6 Data 2 Data 7 Data 3 ANI2 ANI3 Data 4 Data 1 (ANI0) A/D conversion Data 2 (ANI1) Data 1 (ANI0) ADA0CRn Data 3 (ANI2) Data 2 (ANI1) Data 4 (ANI3) Data 3 (ANI2) Data 1 (ANI0) Data 4 (ANI3) Data 2 (ANI1) Data 1 (ANI0) INTAD Transformation completion Conversion start Set ADA0CE bit = 1 (b) Block diagram Analog input pin ADA0CRn register ANI0 ADA0CR0 ANI1 ADA0CR1 ADA0CR2 ANI2 ANI3 A/D converter ADA0CR4 ANI5 ADA0CR5 . . . . ANIm Figure 19-7 686 ADA0CR3 ANI4 . . . ADA0CRm Timing example of one-shot scan mode operation (ADA0S Register = 03H) User's Manual U18743EE1V2UM00 Data 3 (ANI2) Data 2 (ANI1) Data 3 (ANI2) A/D Converter (ADC) (5) Chapter 19 Diagnostic mode When activating the diagnostic mode (ADADIAG bit of ADAnM2 register is set) the voltage at the AVREF pin and the AVSS pin are sampled after conversion of the specified ANInm range is finished. The resulting values can be found in the ADAnCRDD, ADAnCRDDH, ADAnCRSS and ADAnCRSSH registers. Since AD conversion accuracy is influenced of use conditions, the result does not necessarily become all 1 when converting AVREF. Since AD conversion accuracy is influenced of use conditions, the result does not necessarily become all 0 when converting AVSS. (6) Discharge mode When activating the discharge mode (ADAnDISC bit of ADAnM2 register is set) the internal capacitors of the sample and hold circuit are discharged prior to every conversion. Additional 4 clocks must therefore be added to every conversion. User's Manual U18743EE1V2UM00 687 Chapter 19 A/D Converter (ADC) 19.4.4 Power-fail compare mode The A/D conversion end interrupt request signal (INTAD) can be controlled as follows by the ADAnPFM and ADAnPFT registers. * When the ADAnPFE bit = 0, the INTAD signal is generated each time conversion is completed (normal use of the A/D Converter). * When the ADAnPFE bit = 1 and when the ADAnPFC bit = 0, the value of the ADAnCRmH register is compared with the value of the ADAnPFT register when conversion is completed, and the INTAD signal is generated only if ADAnCR0H ADAnPFT. * When the ADAnPFE bit = 1 and when the ADAnPFC bit = 1, the value of the ADAnCRmH register is compared with the value of the ADAnPFT register when conversion is completed, and the INTAD signal is generated only if ADAnCR0H < ADAnPFT. In the power-fail compare mode, four modes are available as modes in which to set the ANInm pins: continuous select mode and continuous scan mode, one-shot select mode and one-shot scan mode. (1) Continuous select mode In this mode, the result of converting the voltage of the analog input pin specified by the ADAnS register is compared with the set value of the ADAnPFT register. If the result of power-fail comparison matches the condition set by the ADAnPFC bit, the conversion result is stored in the ADAnCRm register, and the INTAD signal is generated. If it does not match, the conversion result is stored in the ADAnCRm register, and the INTAD signal is not generated. After completion of the first conversion, the next conversion is started, unless the ADAnCE bit of the ADAnM0 register is cleared to 0. ANI1 Data4 Data1 Data 1 (ANI1) A/D conversion ADA0CR1 Data2 Data3 Data 2 (ANI1) Data 3 (ANI1) Data 4 (ANI1) Data 1 (ANI1) Data 2 (ANI1) Data 3 (ANI1) ADA0PFT unmatch ADA0PFT unmatch ADA0PFT match Data5 Data 5 (ANI1) Data 4 (ANI1) Data6 Data7 Data 6 (ANI1) Data 7 (ANI1) Data 6 (ANI1) INTAD Conversion start Set ADA0CE bit = 1 Figure 19-8 688 ADA0PFT ADA0PFT match match Conversion start Set ADA0CE bit = 1 Timing example of continuous select mode operation (when power-fail comparison is made: ADA0S register = 01H) User's Manual U18743EE1V2UM00 A/D Converter (ADC) (2) Chapter 19 Continuous scan mode In this mode, the results of converting the voltages of the analog input pins sequentially selected from the ANI0 pin to the pin specified by the ADAnS register are stored, and the set value of the ADAnCR0H register of channel 0 is compared with the value of the ADAnPFT register. If the result of power-fail comparison matches the condition set by the ADAnPFC bit of the ADAnPFM register, the conversion result is stored in the ADAnCR0 register, and the INTAD signal is generated. If it does not match, the conversion result is stored in the ADAnCR0 register, and the INTAD signal is not generated. After the result of the first conversion has been stored in the ADAnCR0 register, the results of sequentially converting the voltages on the analog input pins up to the pin specified by the ADAnS register are continuously stored. After completion of conversion, the next conversion is started from the ANI0 pin again, unless the ADAnCE bit of the ADAnM0 register is cleared to 0. User's Manual U18743EE1V2UM00 689 Chapter 19 A/D Converter (ADC) (a) Timing example ANI0 Data 1 Data 5 ANI1 Data 6 Data 2 Data 7 Data 3 ANI2 ANI3 Data 4 Data 1 (ANI0) A/D conversion Data 2 (ANI1) Data 1 (ANI0) ADA0CRn Data 3 (ANI2) Data 2 (ANI1) Data 4 (ANI3) Data 3 (ANI2) Data 5 (ANI0) Data 4 (ANI3) Data 6 (ANI1) Data 5 (ANI0) Data 7 (ANI2) Data 6 (ANI1) INTAD ADA0PFT match ADA0PFT unmatch Conversion start Set ADA0CE bit = 1 (b) Block diagram Analog input pin ADA0CRn registers ANI0 ADA0CR0 ANI1 ADA0CR1 ANI2 ADA0CR2 ANI3 A/D converter ADA0CR4 ANI5 ADA0CR5 . . . . ANIm Figure 19-9 690 ADA0CR3 ANI4 . . . ADA0CRm Timing example of continuous scan mode operation (when power-fail comparison is made: ADA0S register = 03H) User's Manual U18743EE1V2UM00 A/D Converter (ADC) (3) Chapter 19 One-shot select mode In this mode, the result of converting the voltage of the analog input pin specified by the ADA0S register is compared with the set value of the ADA0PFT register. If the result of power-fail comparison matches the condition set by the ADA0PFC bit, the conversion result is stored in the ADA0CRn register, and the INTAD signal is generated. If it does not match, the conversion result is stored in the ADA0CRn register, and the INTAD signal is not generated. Conversion is stopped after it has been completed. Figure 19-10 Timing example of one-shot select mode operation (when power-fail comparison is made: ADA0S register = 01H) User's Manual U18743EE1V2UM00 691 Chapter 19 A/D Converter (ADC) (4) One-shot scan mode In this mode, the results of converting the voltages of the analog input pins sequentially selected from the ANI0 pin to the pin specified by the ADAnS register are stored, and the set value of the ADAnCR0H register of channel 0 is compared with the value of the ADAnPFT register. If the result of power-fail comparison matches the condition set by the ADAnPFC bit of the ADAnPFM register, the conversion result is stored in the ADAnCR0 register, and the INTAD signal is generated. If it does not match, the conversion result is stored in the ADAnCR0 register, and the INTAD signal is not generated. After the result of the first conversion has been stored in the ADAnCR0 register, the results of sequentially converting the voltages on the analog input pins up to the pin specified by the ADAnS register are continuously stored. After completion of conversion, A/D conversion is stopped. The 1st conversion result after A/D conversion has been ignored, because it is not good. 692 User's Manual U18743EE1V2UM00 A/D Converter (ADC) Chapter 19 (a) Timing example ANI0 Data 1 Data 5 ANI1 Data 6 Data 2 Data 7 Data 3 ANI2 ANI3 Data 4 Data 1 (ANI0) A/D conversion Data 2 (ANI1) Data 1 (ANI0) ADA0CRn Data 3 (ANI2) Data 2 (ANI1) Data 4 (ANI3) Data 3 (ANI2) Data 4 (ANI3) INTAD ADA0PFT match Conversion completion Conversion start Set ADA0CE bit = 1 (b) Block diagram Analog input pin ADA0CRn register ANI0 ADA0CR0 ANI1 ADA0CR1 ADA0CR2 ANI2 ANI3 A/D converter ADA0CR4 ANI5 ADA0CR5 . . . . ANIm Figure 19-11 ADA0CR3 ANI4 . . . ADA0CRm Timing Example of One-shot Scan Mode Operation (When Power-Fail Comparison Is Made: ADA0S Register = 03H) User's Manual U18743EE1V2UM00 693 Chapter 19 A/D Converter (ADC) 19.5 Cautions (1) When A/D Converter is not used When the A/D Converter is not used, the power consumption can be reduced by clearing the ADAnCE bit and the ADAnPS bit of the ADAnM0 register to 0. (2) Input range of ANInm pins Input the voltage within the specified range to the ANInm pins. If a voltage equal to or higher than AVREF or equal to or lower than AVSS (even within the range of the absolute maximum ratings) is input to any of these pins, the conversion value of that channel is undefined and the conversion value of the other channels may also be affected. (3) Countermeasures against noise To maintain the 10-bit resolution, the ANInm pins must be effectively protected from noise. The influence of noise increases as the output impedance of the analog input source becomes higher. To lower the noise, connecting an external capacitor as shown in Figure 19-12 is recommended. VDD AVREF ANI0 to ANIn C = 100 to 1,000 pF AVSS VSS Figure 19-12 (4) Processing of analog input pin Alternate I/O The analog input pins ANInm function alternately as port pins. Changing the digital input/output function (PMCn and PMn; n = 2, 7 or 12) or changing the level of one or more output ports (Pnm; n = 2, 7 or 12; m = 0 up to 15) while ADA0CE bit = 1 could degrade the conversion accuracy. For the output port the potential degradation increases with the driven total output current. Also the conversion resolution may drop if the output current fluctuates due to the effect of the external circuit connected to the port pins. 694 User's Manual U18743EE1V2UM00 A/D Converter (ADC) (5) Chapter 19 Interrupt request flag (ADIF) The interrupt request flag (ADIF) is not cleared even if the contents of the ADAnS register are changed. If the analog input pin is changed during A/D conversion, therefore, the result of converting the previously selected analog input signal may be stored and the conversion end interrupt request flag may be set immediately before the ADAnS register is rewritten. If the ADIF flag is read immediately after the ADAnS register is rewritten, the ADIF flag may be set even though the A/D conversion of the newly selected analog input pin has not been completed. When A/D conversion is stopped, clear the ADIF flag before resuming conversion. ADAnS rewrite (ANInk conversion start) A/D conversion ADAnCRm ANInk ADAnS rewrite (ANInl conversion start) ANInk ANInk ADIF is set, but ANInl conversion does not end ANInl ANInk ANInl ANInl ANInl INTADn Figure 19-13 (6) Generation timing of A/D conversion end interrupt request Reading ADAnCRm register When the ADAnM0 to ADAnM2 or ADAnS register is written, the contents of the ADAnCRm register may be undefined. Read the conversion result after completion of conversion and before writing to the ADAnM0 to ADAnM2 and ADAnS registers. The correct conversion result may not be read at a timing different from the above. User's Manual U18743EE1V2UM00 695 Chapter 19 A/D Converter (ADC) 19.6 How to read A/D Converter characteristics table This section describes the terms related to the A/D Converter. For details refer to the Electrical Target Specification (1) Resolution The minimum analog input voltage that can be recognized, i.e., the ratio of an analog input voltage to 1 bit of digital output is called 1 LSB (least significant bit). The ratio of 1 LSB to the full scale is expressed as %FSR (full-scale range). %FSR is the ratio of a range of convertible analog input voltages expressed as a percentage, and can be expressed as follows, independently of the resolution. 1%FSR = = = (Maximum value of convertible analog input voltage - Minimum value of convertible analog input voltage)/100 (AVREF - 0)/100 AVREF/100 When the resolution is 10 bits, 1 LSB is as follows: 1 LSB = = 1/210 = 1/1,024 0.098%FSR The accuracy is determined by the overall error, independently of the resolution. (2) Overall error This is the maximum value of the difference between an actually measured value and a theoretical value. It is a total of zero-scale error, full-scale error, linearity error, and a combination of these errors. The overall error in the characteristics table does not include the quantization error. 696 User's Manual U18743EE1V2UM00 A/D Converter (ADC) Chapter 19 1......1 Digital output Ideal line Overall error 0......0 0 AVREF Analog input Figure 19-14 (3) Overall error Quantization error This is an error of 1/2 LSB that inevitably occurs when an analog value is converted into a digital value. Because the A/D Converter converts analog input voltages in a range of 1/2 LSB into the same digital codes, a quantization error is unavoidable. Digital output 1......1 1/2 LSB Quantization error 1/2 LSB 0......0 0 AVREF Analog input Figure 19-15 Quantization error User's Manual U18743EE1V2UM00 697 Chapter 19 A/D Converter (ADC) (4) Zero-scale error This is the difference between the actually measured analog input voltage and its theoretical value when the digital output changes from 0...000 to 0...001 (1/2 LSB). Digital output (lower 3 bits) 111 Ideal line 100 Zero-scale error 011 010 001 000 -1 0 1 2 3 Analog input (LSB) Figure 19-16 698 Zero-scale error User's Manual U18743EE1V2UM00 AVREF A/D Converter (ADC) (5) Chapter 19 Full-scale error This is the difference between the actually measured analog input voltage and its theoretical value when the digital output changes from 1...110 to 0...111 (full scale - 3/2 LSB). Digital output (lower 3 bits) Full-scale error 111 110 101 100 000 0 AVREF - 3 AVREF - 2 AVREF - 1 AVREF Analog input (LSB) Figure 19-17 (6) Full-scale error Differential linearity error Ideally, the width to output a specific code is 1 LSB. This error indicates the difference between the actually measured value and its theoretical value when a specific code is output. 1......1 Digital output Ideal width of 1 LSB Differential linearity error 0......0 AVREF Analog input Figure 19-18 Differential linearity error User's Manual U18743EE1V2UM00 699 Chapter 19 A/D Converter (ADC) (7) Integral linearity error This error indicates the extent to which the conversion characteristics differ from the ideal linear relationship. It indicates the maximum value of the difference between the actually measured value and its theoretical value where the zero-scale error and full-scale error are 0. 1......1 Digital output Ideal line Integral linearity error 0......0 0 AVREF Analog input Figure 19-19 (8) Integral linearity error Conversion time This is the time required to obtain a digital output after an analog input voltage has been assigned. The conversion time in the characteristics table includes the sampling time. (9) Sampling time This is the time for which the analog switch is ON to load an analog voltage to the sample & hold circuit. Sampling time Conversion time Figure 19-20 700 Sampling time User's Manual U18743EE1V2UM00 Chapter 20 Power Supply Scheme The microcontroller has general power supply pins for its core, internal memory and peripherals. These pins are connected to internal voltage regulators. The microcontroller also has dedicated power supply pins for certain I/O modules. These pins provide the power for the I/O operations. 20.1 Overview The following table gives the naming convention of the pins: Table 20-1 Naming convention of power supply pins Dedicated function VDD or VSS <none> CPU core, internal memory and peripherals A A/D Converter, Low-Voltage Detector B, E Standard I/O buffer * VDD: Voltage Drain Drain * VSS: Voltage for Substrate and Source The following pins belong to the Power Supply Scheme: Note Table 20-2 For electrical characteristics refer to the Electrical Target Specification. Power supply pins Power supply pins AVREF0 / AVSS VDD / VSS V850ES/FE3-L V850ES/FF3-L V850ES/FG3-L A/D Converter 0 / Low-Voltage Detector CPU core (with voltage regulator) EVDD / EVSS - numbered I/O port buffersa - alpha I/O port buffersa numbered I/O port buffersa BVDD / BVSS - alpha I/O port buffersb a) b) numbered ports: port groups 0 to 9 alpha ports: port groups CM, CS, CT, DL User's Manual U18743EE1V2UM00 701 Chapter 20 Power Supply Scheme 20.2 Description Following figures give an overview of the allocation of power supply pins on the chip. Note 702 The diagrams do not show the exact pin location. (1) V850ES/FE3-L, V850ES/FF3-L power supply pins assignment Figure 20-1 V850ES/FE3-L, V850ES/FF3-L power supply pins assignment User's Manual U18743EE1V2UM00 Power Supply Scheme (2) Chapter 20 V850ES/FG3-L power supply pins assignment AVREF0 VDD BVDD I/O buffer A/D converter Regulator Flash memory BVDD REGC Main and Sub oscillators Internal circuit EVDD EVDD I/O buffer Figure 20-2 Bidirectional level shifter V850ES/FG3-L ower supply pins assignment 20.3 Voltage regulators The on-chip voltage regulators generate the voltages for the internal circuitry, refer to Figure 20-1, Figure 20-2. The regulators operate per default in all operation modes (normal operation, HALT, IDLE1, IDLE2, STOP, Sub-clock, and during reset). Note To stabilize the output voltage of the regulator, connect a capacitor to the REGC pin. Refer to the Electrical Target Specification. User's Manual U18743EE1V2UM00 703 Chapter 20 704 Power Supply Scheme User's Manual U18743EE1V2UM00 Chapter 21 Reset Several reset functions are provided in order to initialize hardware and registers. 21.1 Overview Features summary An internal system reset SYSRES can be generated by the following sources: * External reset signal RESET * Power-On-Clear (RESPOC) * Watchdog Timer 2 (RESWDT2) * Clock Monitor (RESCLM) * Low-Voltage Detector (RESLVI) 21.1.1 General reset performance The following figure shows the signals involved in the reset function. NPB RESF 0 0 0 WDT2 RF 0 0 CLMRF LVIRF RESF = 00H RESET RESLVI RESCLM RESWDT2 Figure 21-1 Reset logic circuit RESPOC SYSRES Reset function signal diagram All resets are applied asynchronously. That means, resets are not synchronized to any internal clock. This ensures that the microcontroller can be kept in reset state even if all internal clocks fail to operate. User's Manual U18743EE1V2UM00 705 Chapter 21 Reset (1) Hardware status With each reset function the hardware is initialized. When the reset status is released, program execution is started. The following table describes the status of the clocks and on-chip modules during reset and after reset release. Table 21-1 Hardware status during and after reset Item During reset After reset General clock supplies Refer to "Start conditions" on page 184 On-chip peripheral functions Watch Timer WT Operating on fXT Watchdog Timer WDT2 Stopped Starts operation based on fRL, after internal oscillator stable. all others Stopped Operable based on fRH, after internal oscillator stable. CPU Initialized Program execution starts based on fRH, after internal oscillator stable. I/O pins (port/alternative function pins) All pins are in input port modea. See chapter "Pin Functions" on page 31 for a description. a) 706 The status of the N-Wire debug interface pins DRST (P05), DDI (P52), DDO (P53), DCK (P54), DMS (P55) after reset depends on the reset value of the OCDM register, and therefore on the reset source. See chapter "Pin Functions" on page 31 for details. User's Manual U18743EE1V2UM00 Reset Chapter 21 (2) Register status With each reset function the registers of the CPU, internal RAM, and on-chip peripheral I/Os are initialized. After a reset, make sure to set the registers to the values needed within your program. Table 21-2 Initial values of CPU and internal RAM after reset On-chip hardware CPU Program registers System registers Register name Initial value after Reset General-purpose register (r0) 0000 0000H General-purpose registers (r1 to r31) Undefined Program counter (PC) Reset vector programmed to the code flash memory extra areaa Status save registers during interrupt (EIPC, EIPSW) Undefined Status save registers during nonmaskable interrupt (NMI) (FEPC, FEPSW) Undefined Interrupt cause register (ECR) 0000 0000H Program status word (PSW) 0000 0020H Status save registers during CALLT execution (CTPC, CTPSW) Undefined Status save registers during exception/ debug trap (DBPC, DBPSW) Undefined CALLT base pointer (CTBP) Undefined Internal RAM Peripherals a) Undefined Macro internal registers The reset values of the various registers are given in the chapters of the peripheral functions After reset, the internal Firmware is executed. When execution of the Firmware is finished, it performs a program branch according to the user defined reset vector. The reset vector is stored in the extra flash area. Internal RAM data becomes undefined after power-on reset, or if RAM data access by the CPU and a reset input conflict (data is lost). Addtionally the following resources are used by the internal firmware executed after a reset:: * The first 150 bytes and the last 100 bytes of the available RAM area are undefined. * Program status word (PSW) is undefined, but interrupts are disabled User's Manual U18743EE1V2UM00 707 Chapter 21 Reset 21.1.2 Reset at power-on The Power-On-Clear circuit (POC) permanently compares the power supply voltage VDD with an internal reference voltage (VIP). It ensures that the microcontroller only operates as long as the power supply exceeds a welldefined limit. When the power supply voltage falls below the internal reference voltage (VDD < VIP), the internal reset signal RESPOC is generated. After Power-On-Clear reset, the RESF register is cleared and the internal reset SYSRES is generated. Note 1. Depending on the supply voltage drop rate it may be required to apply an external RESET signal additionally in order to avoid microcontroller operation out of the specified operating conditions. For detailed electrical characteristics refer to the Electrical Target Specification. 2. POC shares the reference voltage supply with the power regulators. Figure 21-2 on page 708 shows the generation of RESPOC by the Power-OnClear circuit. The Power-On-Clear function holds the microcontroller in reset state as long as the power supply voltage does not exceed the threshold level VPOC. Supply voltage (VDD) Internal reference voltage (VPOC) Delay Time RESPOC Reset period Figure 21-2 708 Reset period Reset generation by Power-On-Clear circuit User's Manual U18743EE1V2UM00 Reset period Reset Chapter 21 Figure 21-3 on page 709 outlines the start up of the CPU system after PowerOn-Clear. VDD MainOSC fx Stop MainOSC start possible Stop PLL enable possible 8 MHz internal oscillator fRH Stop PLL output fPLLO CPU system clock fVBCLK CPU system fRH operation RESET analog delay (reset release) Internal reset fRH setup time Figure 21-3 CPU system start up after Power-On-Clear User's Manual U18743EE1V2UM00 709 Chapter 21 Reset 21.1.3 External RESET Reset is performed when a low level signal is applied to the RESET pin. The reset status is released when the signal applied to the RESET pin changes from low to high. After the external RESET is released, the RESF register is cleared and the internal system reset signal SYSRES is generated. The RESET pin incorporates a noise eliminator, which is applied to the reset signal RESET. To prevent erroneous external reset due to noise, it uses an analog filter. Even if no clock is active in the controller the external RESET can keep the controller in reset state. The following figure shows the timing when an external RESET is performed. It explains the effect of the noise eliminator. The noise eliminator uses the analog delay to prevent the generation of an external reset due to noise. The analog delay is caused by the analog input filter. The filter regards pulses up to a certain width as noise and suppresses them. For the minimum RESET pulse width refer to the Electrical Target Specification. MainOSC fx Stop MainOSC start possible Stop PLL enable possible 8 MHz internal oscillator fRH Stop PLL output fPLLO CPU system clock fVBCLK CPU system fPLLO operation CPU system fRH operation RESET analog delay (noise removal) analog delay (reset detection) analog delay (noise removal) analog delay (reset release) Internal reset fRH setup time Figure 21-4 710 Timing for external RESET User's Manual U18743EE1V2UM00 Reset Chapter 21 21.1.4 Reset by Watchdog Timer 2 The Watchdog Timer can be configured to generate a reset if the watchdog time overflows. After watchdog reset, the RESF.WDT2RF bit is set. The system reset signal SYSRES is generated. After Watchdog Timer overflow, the reset status lasts for a specific time. Then the reset status is automatically released. 21.1.5 Reset by Clock Monitor The Clock Monitor generates a reset when the main oscillator fails. After a Clock Monitor reset, the corresponding bit RESF.CLMRF is set. The system reset signal SYSRES is generated. After a Clock Monitor reset, the reset status lasts for a specific time. Then the reset status is automatically released. 21.1.6 Reset by Low-Voltage Detector The Low-Voltage Detector can be configured to generate the reset RESLVI if the voltage supply VDD falls below the reference voltage VLVI. RESLVI sets the bit RESF.LVIRF and the system reset SYSRES is generated. User's Manual U18743EE1V2UM00 711 Chapter 21 Reset 21.2 Reset Registers The reset functions are controlled and operated by means of the following registers: Table 21-3 (1) Reset function register overview Register name Shortcut Address Reset source flag register RESF FFFF F888H RESF - Reset source flag register The 8-bit RESF register contains information about which type of resets occurred since the last Power-On-Clear or external RESET. The RESF register is a special register that can be written only by specific sequences. Each following reset condition sets the corresponding flag in the register. For example, if a Power-On-Clear reset is finished and then a Watchdog Timer reset occurs, the RESF reads 0001 0000B. Access Address Initial Value Table 21-4 The register can be read/written in 8-bit units and 1-bit units. FFFF F888H Power-On-Clear reset and external RESET sets this register to 00H. 7 6 5 4 3 2 1 0 0 0 0 WDT2RF 0 0 CLMRF LVIRF R R R R/W R R R/W R/W RESF register contents Bit position Note 712 Bit name Function 4 WDT2RF Reset by Watchdog Timer 0: Not generated. 1: Generated. 1 CLMRF Reset by Clock Monitor 0: Not generated. 1: Generated. 0 LVIRF Reset by Low-Voltage Detector 0: Not generated. 1: Generated. If clearing this register by writing and flag setting (occurrence of reset) conflict, flag setting takes precedence. User's Manual U18743EE1V2UM00 Chapter 22 Low-Voltage Detector This chapter describes the Low-Voltage Detector and the RAM data rentention function. 22.1 Functions The Low-Voltage Detector (LVI) has the following functions. * Compares the supply voltage (VDD) with a reference voltage (VLVI) and generates - internal interrupt signals when VDD < VLVI or VDD > VLVI - or internal reset signal when VDD < VLVI. * The level of the supply voltage to be detected can be changed by software (in two steps). * Interrupt or reset signal can be selected by software. * Can operate in STOP mode. * Operation can be stopped by software. If the Low-Voltage Detector is used to generate a reset signal, bit 0 (LVIRF) of the reset source flag register (RESF) is set to 1 when the reset signal is generated. For details of RESF, refer to "Reset" on page 705. 22.2 Configuration Figure 22-1 shows the block diagram of the Low-Voltage Detector. User's Manual U18743EE1V2UM00 713 Chapter 22 Low-Voltage Detector VDD VDD Low voltage detection level selector N-ch Selector Internal reset signal + - INTLVIH INTLVIL Reference voltage source (VLVI) LVIS0 LVION LVIMD Low voltage detection level selection register (LVIS) LVIF Low voltage detection register (LVIM) Internal bus Figure 22-1 Block diagram of Low-Voltage Detector 22.3 Registers The Low-Voltage Detector is controlled by the following registers. * Low voltage detection register (LVIM) * Low voltage detection level selection register (LVIS) (1) LVIM - Low voltage detection register This register is a special register and can be written only in a combination of specific sequences (refer to "Write Protected Registers" on page 155). The LVIM register is used to enable or disable low voltage detection, and to set the operation mode of the Low-Voltage Detector. This register can be read or written in 8-bit or 1-bit units. Reset input clears this register to 00H. After reset: 00H LVIM LVION 714 R/W Address: FFFFF890H 7 6 5 4 3 2 1 0 LVION 0 0 0 0 0 LVIMD LVIF Low voltage detection operation enable or disable 0 Disable operation. 1 Enable operation. User's Manual U18743EE1V2UM00 Low-Voltage Detector Chapter 22 LVIMD Selection of operation mode of low voltage detection 0 Generate interrupt request signal * INTLVIL when supply voltage VDD < reference voltage VLVI * INTLVIH when supply voltage VDD > reference voltage VLVI 1 Generate internal reset signal LVIRES when supply voltage VDD < reference voltage VLVI LVIF Caution Low voltage detection flag 0 When * supply voltage VDD > reference voltage VLVI or * operation is disabled (LVIM.LVION = 0) 1 Supply voltage of power supply VDD < reference voltageVLVI 1. After setting the LVIM.LVION bit to 1, wait for a specified time before checking the voltage using the LVIM.LVIF bit. The wait time is specified in the Electrical Target Specification. 2. The LVIIF bit is valid only when the LVIM.LVION = 1 and LVIM.LVIMD = 0. 3. The LVIM.LVIF bit is read-only. 4. Be sure to clear bits 2 to 6 to 0. User's Manual U18743EE1V2UM00 715 Chapter 22 Low-Voltage Detector (2) LVIS - Low voltage detection level selection register The LVIS register is used to select the level of low voltage to be detected. This register can be read or written in 8-bit units. Reset input clears this register to 00H. After reset: 00H LVIS R/W Address: FFFFF891H 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 LVIS0 LVIS0 a) Caution Detection level Va 0 4.0 1 3.7 Va Refer to Electrical Target Specification for the detailed specification. 1. This register cannot be written until a reset request due to something other than low-voltage detection is generated after the LVIM.LVION and LVIM.LVIMD bits are set to 1. 2. Be sure to clear bits 7 to 1 to 0. 716 User's Manual U18743EE1V2UM00 Low-Voltage Detector (3) Chapter 22 RAMS - Internal RAM data status register The RAMS register is a flag register that indicates that the supply voltage has dropped below a specific data retention voltage. If so, the contents of the RAM may have changed and has to be considered as invalid. This register can be read or written in 8-bit or 1-bit units. Writing to this register is protected by a special sequence of instructions. Please refer to "Write Protected Registers" on page 155 for details. After reset: Note RAMS R/W Address: FFFFF892H 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 RAMF RAMF Internal RAM data valid/invalid 0 supply voltage > data retention voltage, RAM valid 1 supply voltage < data retention voltage, RAM invalid For the specification of the data rentention voltage, consult the Electrical Target Specification. Note This register is not influenced by any reset. Refer to 22.4.4 on page 722 for further details concerning RAM data retention. User's Manual U18743EE1V2UM00 717 Chapter 22 Low-Voltage Detector (4) PEMU1 - Peripheral emulation register 1 When an in-circuit emulator is used, the operation of the RAM retention flag (RAMF bit: bit 0 of RAMS register) can be pseudo-controlled and emulated by manipulating this register on the debugger. This register can be read or written in 8-bit or 1-bit units. This register is valid only in the emulation mode. It is invalid in the normal mode. After reset: 00H PEMU1 EVARAMIN Caution R/W Address: FFFFF9FEH 7 6 5 4 3 2 1 0 0 0 0 0 0 EVARAMIN 0 0 Pseudo specification of RAM retention voltage detection signal 0 Do not detect voltage lower than RAM retention voltage. 1 Detect voltage lower than RAM retention voltage (set RAMF flag). This bit is not automatically cleared. [Usage] When an in-circuit emulator is used, pseudo emulation of RAMF is realized by rewriting this register on the debugger. 718 <1> CPU break (CPU operation stops.) <2> Set the EVARAMIN bit to 1 by using a register write command. By setting the EVARAMIN bit to 1, the RAMF bit is set to 1 on hardware (the internal RAM data is invalid). <3> Clear the EVARAMIN bit to 0 by using a register write command again. Unless this operation is performed (clearing the EVARAMIN bit to 0), the RAMF bit cannot be cleared to 0 by a CPU operation instruction. <4> Run the CPU and resume emulation. User's Manual U18743EE1V2UM00 Low-Voltage Detector Chapter 22 22.4 Operation Depending on the setting of the LVIMD bit, the interrupt signals (INTLVIL, INTLVIH) or an internal reset signal is generated. How to specify each operation is described below, together with timing charts. 22.4.1 Reset generation from LVI (LVIM.LVIMD = 1) Operation start 1. Mask the interrupt of LVI. 2. Select the voltage to be detected by using the LVIS.LVIS0 bit. 3. Set the LVIM.LVION bit to 1 (to enable operation). 4. Insert sufficient wait time by software. See the Electrical Target Specification for details. 5. By using the LVIM.LVIF bit, check if the supply voltage VDD > reference voltage VLVI. 6. Set the LVIM.LVIMD bit to 1 (to generate an internal reset signal). Caution If LVIM.LVIMD is set to 1, the contents of the LVIM and LVIS registers cannot be changed until a reset request other than LVI is generated. User's Manual U18743EE1V2UM00 719 Chapter 22 Low-Voltage Detector Supply voltage (VDD) LVI detection voltage (VLVI) POC detection voltage (VPOC) Time LVIM.LVION D D D RESLVI Cleared by instruction RESF.LVIRF D D D RESPOC SYSRES D Figure 22-2 Note : Delay of analog circuitry Operation timing of Low-Voltage Detector (LVIMD = 1) During the period in which the supply voltage is the set low voltage or lower, the internal reset signal is retained (internal reset state). 22.4.2 Interrupt generation from LVI (LVIM.LVIMD = 0) Operation start 1. Mask the interrupts of LVI. 2. Select the voltage to be detected by using the LVIS.LVIS0 bit. 3. Set the LVIM.LVION bit to 1 (to enable operation). 4. Insert sufficient wait time by software. See the Electrical Target Specification for details. 5. By using the LVIM.LVIF bit, check if the supply voltage VDD > reference voltage VLVI. 6. Clear the interrupt request flag of LVI. 7. Unmask the interrupt of LVI. stop 1. Mask the interrupt INTLVIH by setting LVIHMK to 1. 2. Clear the LVIM.LVION bit to 0. 3. Clear the interrupt request flag LVIHIF of INTLVIH 720 User's Manual U18743EE1V2UM00 Low-Voltage Detector Chapter 22 Supply voltage (VDD) LVI detection voltage (VLVI) POC detection voltage (VPOC) Time LVIM.LVION D D INTLVIL D INTLVIH LVIM.LVIF D D D RESPOC SYSRES D Figure 22-3 Note : Delay of analog circuitry Operation timing of Low-Voltage Detector (LVIM.LVIMD = 0) If VDD is fluctuating around the LVI detection level (VLVI), note that the judgment upon the INTLVIH or INTLVIL interrupt servicing may be incorrect. For example, if during INTLVIL interrupt servicing multiple INTLVIH/INTLVIL interrupts are generated due to the VDD fluctuation, it cannot be detected which interrupt was generated last. Consequently, when INTLVIL interrupt servicing is performed at the last, even though VDD > VLVI, software detects VDD < VLVI by mistake. Therefore when LVI detection interrupt servicing is performed, program the software code as to complete interrupt servicing before the next LVI detection is generated, at the same time as controlling the VDD, or monitoring the LVIF flag. 22.4.3 Disabling the LVI operation 1. Mask the interrupt INTLVIH by setting LVIHMK to 1. 2. Disable the LVI operation by setting the LVIM. LVON bit to 0. 3. Clear the interrupt request flag LVIHIF of the INTLVIH register. User's Manual U18743EE1V2UM00 721 Chapter 22 Low-Voltage Detector 22.4.4 RAM retention voltage detection operation The supply voltage and the data retention voltage are compared. When the supply voltage drops below the data retention voltage (including power on application), the RAMS.RAMF bit is set. For the specification of the data retention voltage, consult the Electrical Target Specification. The RAMS.RAMF flag behaves as follows: * After power up the RAMS.RAMF is set. * RAMS.RAMF can only be reset by software. * RAMS.RAMF remains 0 as long as the supply voltage exceeds the data retention voltage. * The RAMS.RAMF flag is not influenced by any reset. * If the supply voltage drops below the power-on-clear reference voltage, but stays above the data retention voltage, a POC reset is applied, but RAMS.RAMF remains 0. Caution If an external RESET is applied during a RAM access of the CPU, parts of the RAM content may have changed accidentally. Such event does not set RAMS.RAMF. VDD POC detection voltage RAM data detection voltage time POCRES RAMS.RAMF power up Figure 22-4 722 clear by software RAMF remains "1" Power-on-clear and RAM data retention detection behaviour User's Manual U18743EE1V2UM00 Chapter 23 On-Chip Debug Unit The microcontroller includes an on-chip debug unit. By connecting an N-Wire emulator, on-chip debugging can be executed. 23.1 Functional Outline 23.1.1 Debug functions (1) Debug interface Communication with the host machine is established by using the DRST, DCK, DMS, DDI, and DDO signals via an on-chip debug emulator. The communication specifications of N-Wire are used for the interface. (2) On-chip debug On-chip debugging can be executed by preparing wiring and a connector for on-chip debugging on the target system. An on-chip debug emulator is used to connect the host PC to the on-chip debug unit. (3) Forced reset function The microcontroller can be forcibly reset. (4) Break reset function The CPU can be started in the debug mode immediately after reset of the CPU is released. (5) Forced break function Execution of the user program can be forcibly aborted. (6) Hardware break function Two breakpoints for instruction and data access can be used. The instruction breakpoint can abort program execution at any address. The access breakpoint can abort program execution by data access to any address. (7) Software break function Up to four software breakpoints can be set in the internal code flash memory area. The number of software breakpoints that can be set in the RAM area differs depending on the debugger to be used. User's Manual U18743EE1V2UM00 723 Chapter 23 On-Chip Debug Unit (8) Debug monitor function A memory space for debugging that is different from the user memory space is used during debugging (background monitor mode). The user program can be executed starting from any address. While execution of the user program is aborted, the user resources (such as memory and I/O) can be read and written, and the user program can be downloaded. (9) Mask function Each of the following signals can be masked. That means these signals will not be effective during debugging. The correspondence between the maskable signals and on-chip debug emulator mask functions are shown below. * NMI0 mask function: NMI pin * NMI1 mask function: WDT2 interrupt * HOLD mask function: HLDRQ pin * RESET mask function: RESET pin, WDT2 reset, POC resetNote, LVI reset, clock monitor reset * WAIT mask function: WAIT pin Note (10) Available in products with the POC function Timer function The execution time of the user program can be measured. (11) Peripheral macro operation/stop selection function during break Depending on the debugger to be used, certain peripheral macros can be configured to continue or to stop operation upon a breakpoint hit. * Functions that are always stopped during break - Watchdog Timer 2 - Clock Monitor * Functions that can operate or be stopped during break (however, each function cannot be selected individually) - all timers AA - Timer M - Watch Timer * Peripheral functions that continue operating during break (functions that cannot be stopped) - Peripheral functions other than above (12) Function during power saving modes When the device is set into a power saving mode, debug operation is not possible. When exiting the power save mode, the on-chip debug unit continues operation. The N-Wire interface is still accessible during power saving modes: * N-Wire emulator can get status information from the on-chip debug unit. * Stop mode can be released by the N-Wire emulator. 724 User's Manual U18743EE1V2UM00 On-Chip Debug Unit (13) Chapter 23 Security function This microcontroller has a N-Wire security function, that demands the user to input an ID code upon start of the debugger. For further information concerning N-Wire security, refer to "Data Protection and Security" on page 289. User's Manual U18743EE1V2UM00 725 Chapter 23 On-Chip Debug Unit 23.2 Controlling the N-Wire Interface The N-Wire interface pins DRST, DDI, DDO, DCK, DMS are shared with port functions, see Table 23-1. During debugging the respective device pins are forced into the N-Wire interface mode and port functions are not available. Note that N-Wire debugging must be generally permitted by the security bit in the ID code region (*0x0000 0079[bit7] = 1) of the code flash memory. An internal pull-down resistor - detachable by software - is provided at the DRST pin to keep the N-Wire interface in reset, if no debugger is connected. Table 23-1 N-Wire interface pins N-Wire function GPIO (1) Pin Direction Description P05 DRST Input N-Wire RCU reset P52 DDI Input N-Wire debug data in P53 DDO Output N-Wire debug data out P54 DCK Input N-Wire interface clock P55 DMS Input N-Wire mode OCDM - On-chip debug mode register The OCDM register is used to select the normal operation mode or on-chip debug mode. . Writing to this register is protected by a special sequence of instructions. Please refer to "CPU System Functions" on page 135 for details. Access Address The register can be read or written in 8-bit and 1-bit units. FFFF F9FCH 7 6 5 4 3 2 1 0 Bit name 0 0 0 0 0 0 0 OCDM0 Reset value 0 0 0 0 0 0 0 0/1a a) Reset value depends on reset source (see below) OCDM0 0 * pins used as port/alternative function pins * internal pull-down resistor detached from P05/DRST 1 * pins used as N-Wire interface pins * internal pull-down resistor attached to P05/DRST The reset value of OCDM.OCDM0 depends on the reset source. (2) Power-On-Clear RESPOC RESPOC (Power-On-Clear) reset sets OCDM.OCDM0 = 0, i.e. the pins are defined as port pins. The debugger can not communicate with the controller 726 User's Manual U18743EE1V2UM00 On-Chip Debug Unit Chapter 23 and the N-Wire debug circuit is disabled. The first CPU instructions after RESPOC can not be controlled by the debugger. The application software must set OCDM.OCDM0 = 1 in order to enable the N-Wire interface and allow debugger access to the on-chip debug unit. During and after POC reset (OCDM.OCDM0 = 0) pins P05, P52...P55 are configured as input ports. (3) External RESET External reset by the RESET pin sets OCDM.OCDM0 = 1, i.e. the pins are defined as N-Wire interface pins. If connected the debugger can communicate with the on-chip debug unit and take over CPU control. During and after RESET the pins P05, P52...P55 are configured as follows: * DRST, DDI, DCK, DMS are inputs. * DDO is output, but in high impedance state as long as DRST = 0. (4) Other resets Resets from all other reset sources do not affect the pins P05, P52...P55. An internal pull-down resistor is provided for the pin P05/DRST. During and after any reset the resistor is connected to P05/DRST, ensuring that the N-Wire interface is kept in reset state, if no debugger is connected. The internal pull-down resistor is connected by reset from any source and can be disconnected via OCDM.OCDM0. The DRST signal depicts the N-Wire interface reset signal. If DRST = 0 the on-chip debug unit is kept in reset state and does not impact normal controller operation. DRST is driven by the debugger, if one is connected. The debugger may start communication with the controller by setting DRST = 1. Pin configuration In N-Wire debug mode the configuration of the N-Wire interface pins can not be changed by the pin configuration registers. The registers contents can be changed but will have no effect on the pin configuration. User's Manual U18743EE1V2UM00 727 Chapter 23 On-Chip Debug Unit 23.3 N-Wire Enabling Methods The current operation mode of the microcontroller is determined by OCDM.OCDM0 and DRST: Table 23-2 Normal operation and debug mode control DRST OCDM.OCDM0 0 X Mode normal operation 0 1 1 on-chip debug 23.3.1 Starting normal operation after RESET and RESPOC For "normal operation" it has to be assured that the pins P05, P52...P55 are available as port pins after either reset event. Therefore the software has to perform OCDM.OCDM0 = 0 to make the pins available as port pins after RESET. Note that after any external reset via the RESET pin OCDM.OCDM0 is set to "1" and the pins P05, P52...P55 are not available as application function pins until the software sets OCDM.OCDM0 = 0. Power on RESPOC RESET application software sets OCDM.OCDM0PC = 0 "1" "0" OCDM0 DRST reset Figure 23-1 normal operation reset normal operation Start without N-Wire activation 23.3.2 Starting debugger after RESET and RESPOC The software has to set OCDM.OCDM0 = 1 for enabling the N-Wire interface also upon a RESPOC event. Afterwards the debugger may start to establish communication with the controller by setting the DRST pin to high level and to take control over the CPU. On start of the debugger the entire controller is reset, i.e. all registers are set to their default states and the CPU's program counter is set to the reset vector 0000 0000H. Note 728 After RESPOC the controller is operating without debugger control. Thus all CPU instructions until the software performs OCDM.OCDM0 = 1 can not be debugged. To restart the user's program from beginning under the debugger's control apply an external RESET after the debugger has started, as shown in User's Manual U18743EE1V2UM00 On-Chip Debug Unit Chapter 23 Figure 23-2. This will cause the program to restart. However the status of the controller might not be the same as immediately after RESPOC, since the internal RAM may have already been initialized, when the external RESET is applied. Power on RESPOC application software sets OCDM.OCDM0 = 1 RESET "0" OCDM0 DRST reset Figure 23-2 normal operation debug Start with N-Wire activation 23.3.3 N-Wire activation by RESET pin The N-Wire interface can also be activated after power up by keeping RESET active after RESPOC is released. By this OCDM.OCDM0 is set to "1", thus the N-Wire interface is enabled. With this method the user's program does not need to perform OCDM.OCDM0 = 1. Power on RESPOC RESET "0" OCDM0 "1" debugger starts PC = 0 DRST reset normal operation debug >= 2 s Figure 23-3 N-Wire activation by RESET pin User's Manual U18743EE1V2UM00 729 Chapter 23 On-Chip Debug Unit 23.4 Connection to N-Wire Emulator To connect the N-Wire emulator, a connector for emulator connection and a connection circuit must be mounted on the target system. As a connector example the KEL connector is described in more detail. Other connectors, like for instance MICTOR connector (product name: 2-767004-2, Tyco Electronics AMP K.K.), are available as well. For the mechanical and electrical specification of these connectors refer to user's manual of the emulator to be used. 23.4.1 KEL connector KEL connector product names: * 8830E-026-170S (KEL): straight type * 8830E-026-170L (KEL): right-angle type Figure 23-4 730 Connection to N-Wire emulator (NEC Electronics IE-V850E1-CD-NW: N-Wire Card) User's Manual U18743EE1V2UM00 On-Chip Debug Unit (1) Chapter 23 Pin configuration Figure 23-5 shows the pin configuration of the connector for emulator connection (target system side), and Table 23-3 on page 732 shows the pin functions. Figure 23-5 Caution Pin configuration of connector for emulator connection (target system side) Evaluate the dimensions of the connector when actually mounting the connector on the target board. User's Manual U18743EE1V2UM00 731 Chapter 23 On-Chip Debug Unit (2) Pin functions The following table shows the pin functions of the connector for emulator connection (target system side). "I/O" indicates the direction viewed from the device. Table 23-3 Pin functions of connector for emulator connection (target system side) Pin no. Pin name I/O Pin function A1 (Reserved 1) - (Connect to GND) A2 (Reserved 2) - (Connect to GND) A3 (Reserved 3) - (Connect to GND) A4 (Reserved 4) - (Connect to GND) A5 (Reserved 5) - (Connect to GND) A6 (Reserved 6) - (Connect to GND) A7 DDI Input Data input for N-Wire interface A8 DCK Input Clock input for N-Wire interface A9 DMS Input Transfer mode select input for N-Wire interface A10 DDO Output Data output for N-Wire interface A11 DRST Input On-chip debug unit reset input A12 RESET Input Reset input. (In a system that uses only POC reset and not pin reset, some emulators input an external reset signal as shown in Figure 23-6 on page 733 to set the OCDM0 bit to 1.) A13 FLMD0 Input Control signal for flash download (flash memory versions only) B1 GND - - B2 GND - - B3 GND - - B4 GND - - B5 GND - - B6 GND - - B7 GND - - B8 GND - - B9 GND - - B10 GND - - B11 (Reserved 8) - (Connect to GND) B12 (Reserved 9) - (Connect to GND) B13 VDD - 5 V input (for monitoring power supply to target) Caution 1. The connection of the pins not supported by the microcontroller is dependent upon the emulator to be used. 2. The pattern of the target board must satisfy the following conditions. * The pattern length must be 100 mm or less. * The clock signal must be shielded by GND. 732 User's Manual U18743EE1V2UM00 On-Chip Debug Unit (3) Chapter 23 Example of recommended circuit An example of the recommended circuit of the connector for emulator connection (target system side) is shown below. 5V V850 KEL connector 8830E-026-170S A1 A2 A3 A4 A5 A6 DDI DCK DMS DDO DRST FLMD0 RESET Note 1 Note 2 Note 1 Note 1 Note 1 A7 A8 A9 A10 A11 Note 1 A13 Note 4 A12 Figure 23-6 Note (Reserved 1) (Reserved 2) (Reserved 3) (Reserved 4) (Reserved 5) (Reserved 6) DDI DCK DMS DDO DRST FLMD0 VDDNote 3 GND GND GND GND GND GND GND GND GND GND (Reserved 8) (Reserved 9) B13 B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 5V B11 B12 RESET Example of recommended emulator connection circuit 1. The pattern length must be 100 mm or less. 2. Shield the DCK signal by enclosing it with GND. 3. This pin is used to detect power to the target board. Connect the voltage of the N-Wire interface to this pin. 4. In a system that uses only POC reset and not pin reset, some emulators input an external reset signal as shown in Figure 23-6 to set the OCDM.OCDM0 bit to 1. Caution The N-Wire emulator may not support a 5 V interface and may require a level shifter. Refer to the user's manual of the emulator to be used. User's Manual U18743EE1V2UM00 733 Chapter 23 On-Chip Debug Unit 23.5 Restrictions and Cautions on On-Chip Debug Function * Do not mount a device that was used for debugging on a mass-produced product (this is because the code flash memory was rewritten during debugging and the number of rewrites of the code flash memory cannot be guaranteed). * If a reset signal (reset input from the target system or reset by an internal reset source) is input during RUN (program execution), the break function may malfunction. * Even if reset is masked by using a mask function, the I/O buffer (port pin, etc.) is reset when a pin reset signal is input. * With a debugger that can set software breakpoints in the internal code flash memory, the breakpoints temporarily become invalid when pin reset or internal reset is effected. The breakpoints become valid again if a break such as a hardware break or forced break is executed. Until then, no software break occurs. * The RESET signal input is masked during a break. * The POC reset operation cannot be emulated. * The on-chip debugging unit uses the exception vector address 60H for software breakpoint (DBTRAP, refer to "Interrupt Controller (INTC)" on page 221). Thus the debugger takes over control when one of the following exceptions occur: - debug trap (DBTRAP) - illegal op-code detection (ILGOP) - ROM Correction The debugger executes its own exception handler. Therefore, the user's exception handler at address 60H will not be executed. * When executing on-chip debugging, pin reset must be input to set the OCDM0 bit of the OCDM register to 1. For details, refer to 23.2"Controlling the N-Wire Interface" on page 726. * When the break command is started in on-chip debug (OCD) mode and the application software accesses to the UARTD/CSIB/CAN peripheral I/O registers, CSIB, UARTD and CAN do not operate normally if on-chip debugging is restarted without executing reset. Caution 734 If the flash memory is programmed during a debug session and the options bytes have been changed, a target reset command has to be issued in order to make the new option byte settings effective. User's Manual U18743EE1V2UM00 Chapter 24 Differences Fx3-L to Fx3 The following table give a short overview of the main differences between the Fx3-L series of devices and the Fx3 series of devices. Table 24-1 Feature Fx3-L Fx3 Operation speed 20 MHz 32Mhz Data Flash Not available 32Kb DMA Not available 4 channels TAB Not available 1 channel (FE3, FF3) 2 channnels (FG3) CAN 1 channel 1 channel (FE3, FF3) 2 channels (FG3) SSCG Not available Available User's Manual U18743EE1V2UM00 735 Chapter 24 736 Differences Fx3-L to Fx3 User's Manual U18743EE1V2UM00 Appendix A Special Function Registers The following tables list all registers that are accessed via the NPB (NEC peripheral bus). The registers are called "special function registers" (SFR). Table A-1 lists all CAN special function registers. The addresses are given as offsets to the programmable peripheral base address (refer to "CAN module register and message buffer addresses" on page 553. The tables list all registers and do not distinguish between the different derivatives. A.1 CAN Registers The CAN registers are accessible via the programmable peripheral area. Table A-1 Address offset CAN special function registers (1/2) Register name Shortcut 1 8 16 32 0x000 CAN0 global control register C0GMCTRL - - R/W - 0x002 CAN0 global clock selection register C0GMCS - R/W - - 0x006 CAN0 global automatic block transmission register C0GMABT - - R/W - 0x008 CAN0 global automatic block transmission delay register C0GMABTD - R/W - - 0x040 CAN0 module mask 1 register C0MASK1L - - R/W - C0MASK1H - - R/W - C0MASK2L - - R/W - C0MASK2H - - R/W - C0MASK3L - - R/W - C0MASK3H - - R/W - C0MASK4L - - R/W - C0MASK4H - - R/W - 0x042 0x044 CAN0 module mask 2 register 0x046 0x048 CAN0 module mask 3 register 0x04A 0x04C CAN0 module mask 4 register 0x04E 0x050 CAN0 module control register C0CTRL - - R/W - 0x052 CAN0 module last error code register C0LEC - R/W - - 0x053 CAN0 module information register C0INFO - R - - 0x054 CAN0 module error counter register C0ERC - - R - 0x056 CAN0 module interrupt enable register C0IE - - R/W - 0x058 CAN0 module interrupt status register C0INTS - - R/W - 0x05A CAN0 module bit-rate prescaler register C0BRP - R/W - - 0x05C CAN0 module bit-rate register C0BTR - - R/W - 0x05E CAN0 module last in-pointer register C0LIPT - R - - 0x060 CAN0 module receive history list register C0RGPT - - R/W - 0x062 CAN0 module last out-pointer register C0LOPT - R - - User's Manual U18743EE1V2UM00 737 Appendix A Special Function Registers Table A-1 Address offset CAN special function registers (2/2) Register name Shortcut 1 8 16 32 0x064 CAN0 module transmit history list register C0TGPT - - R/W - 0x066 CAN0 module time stamp register C0TS - - R/W - 0x100 to 0x4EF CAN0 Message Buffer registers, see Table 18-20 on page 556 738 User's Manual U18743EE1V2UM00 Special Function Registers Appendix A A.2 Other Special Function Registers Table A-2 Other special function registers (1/9) Address Register name Shortcut 1 8 16 32 0xFFFFF004 PortDL PDL - - R/W - 0xFFFFF004 PortDL low byte PDLL R/W R/W - - 0xFFFFF005 PortDL high byte PDLH R/W R/W - - 0xFFFFF008 PortCS PCS R/W R/W - - 0xFFFFF00A PortCT PCT R/W R/W - - 0xFFFFF00C PortCM PCM R/W R/W - - 0xFFFFF024 PortDL mode PMDL R/W - 0xFFFFF024 PortDL mode low byte PMDLL R/W R/W - - 0xFFFFF025 PortDL mode high byte PMDLH R/W R/W - - 0xFFFFF028 PortCS mode PMCS R/W R/W - - 0xFFFFF02A PortCT mode PMCT R/W R/W - - 0xFFFFF02C PortCM mode PMCM R/W R/W - - 0xFFFFF044 PortDL mode control PMCDL R/W - 0xFFFFF044 PortDL mode control low byte PMCDLL R/W R/W - - 0xFFFFF045 PortDL mode control high byte PMCDLH R/W R/W - - 0xFFFFF048 PortCS mode control PMCCS R/W R/W - - 0xFFFFF04A PortCT mode control PMCCT R/W R/W - - 0xFFFFF04C PortCM mode control PMCCM R/W R/W - - 0xFFFFF064 Peripheral I/O area select control register BPC R/W - 0xFFFFF06E System wait control register VSWC - - 0xFFFFF100 Interrupt mask control register 0 IMR0 R/W - 0xFFFFF100 Interrupt mask control register 0L IMR0L R/W R/W - - 0xFFFFF101 Interrupt mask control register 0H IMR0H R/W R/W - - 0xFFFFF102 Interrupt mask control register 1 IMR1 R/W - 0xFFFFF102 Interrupt mask control register 1L IMR1L R/W R/W - - 0xFFFFF103 Interrupt mask control register 1H IMR1H R/W R/W - - 0xFFFFF104 Interrupt mask control register 2 IMR2 R/W - 0xFFFFF104 Interrupt mask control register 2L IMR2L R/W R/W - - 0xFFFFF105 Interrupt mask control register 2H IMR2H R/W R/W - - 0xFFFFF106 Interrupt mask control register 3 IMR3 R/W - 0xFFFFF106 Interrupt mask control register 3L IMR3L R/W R/W - - 0xFFFFF107 Interrupt mask control register 3H IMR3H R/W R/W - - 0xFFFFF108 Interrupt mask control register 4 IMR4 R/W - 0xFFFFF108 Interrupt mask control register 4L IMR4L R/W R/W - - 0xFFFFF109 Interrupt mask control register 4H IMR4H R/W R/W - - 0xFFFFF10A Interrupt mask control register 5 IMR5 R/W - 0xFFFFF10A Interrupt mask control register 5L IMR5L R/W R/W - - 0xFFFFF10B Interrupt mask control register 5H IMR5H R/W R/W - - 0xFFFFF10C Interrupt mask control register 6 IMR6 R/W - User's Manual U18743EE1V2UM00 - - - - - - R/W R/W - - - - - - - - - - - - - - 739 Appendix A Special Function Registers Table A-2 Other special function registers (2/9) Address Register name Shortcut 0xFFFFF10C Interrupt mask control register 6L IMR6L 0xFFFFF10D Interrupt mask control register 6H IMR6H 0xFFFFF10E Interrupt mask control register 7 IMR7 0xFFFFF10E Interrupt mask control register 7L IMR7L 0xFFFFF110 Interrupt control register 0xFFFFF112 16 32 R/W R/W - - R/W R/W - - R/W - R/W R/W - - LVILIC R/W R/W - - Interrupt control register LVIHIC R/W R/W - - 0xFFFFF114 Interrupt control register PIC0 R/W R/W - - 0xFFFFF116 Interrupt control register PIC1 R/W R/W - - 0xFFFFF118 Interrupt control register PIC2 R/W R/W - - 0xFFFFF11A Interrupt control register PIC3 R/W R/W - - 0xFFFFF11C Interrupt control register PIC4 R/W R/W - - 0xFFFFF11E Interrupt control register PIC5 R/W R/W - - 0xFFFFF120 Interrupt control register PIC6 R/W R/W - - 0xFFFFF122 Interrupt control register PIC7 R/W R/W - - 0xFFFFF12E Interrupt control register TAA0OVIC R/W R/W - - 0xFFFFF130 Interrupt control register TAA0CCIC0 R/W R/W - - 0xFFFFF132 Interrupt control register TAA0CCIC1 R/W R/W - - 0xFFFFF134 Interrupt control register TAA1OVIC R/W R/W - - 0xFFFFF136 Interrupt control register TAA1CCIC0 R/W R/W - - 0xFFFFF138 Interrupt control register TAA1CCIC1 R/W R/W - - 0xFFFFF13A Interrupt control register TAA2OVIC R/W R/W - - 0xFFFFF13C Interrupt control register TAA2CCIC0 R/W R/W - - 0xFFFFF13E Interrupt control register TAA2CCIC1 R/W R/W - - 0xFFFFF140 Interrupt control register TAA3OVIC R/W R/W - - 0xFFFFF142 Interrupt control register TAA3CCIC0 R/W R/W - - 0xFFFFF144 Interrupt control register TAA3CCIC1 R/W R/W - - 0xFFFFF146 Interrupt control register TAA4OVIC R/W R/W - - 0xFFFFF148 Interrupt control register TAA4CCIC0 R/W R/W - - 0xFFFFF14A Interrupt control register TAA4CCIC1 R/W R/W - - 0xFFFFF14C Interrupt control register TM0EQIC0 R/W R/W - - 0xFFFFF14E Interrupt control register CB0RIC R/W R/W - - 0xFFFFF150 Interrupt control register CB0TIC R/W R/W - - 0xFFFFF152 Interrupt control register CB1RIC R/W R/W - - 0xFFFFF154 Interrupt control register CB1TIC R/W R/W - - 0xFFFFF156 Interrupt control register UD0SIC R/W R/W - - 0xFFFFF158 Interrupt control register UD0RIC R/W R/W - - 0xFFFFF15A Interrupt control register UD0TIC R/W R/W - - 0xFFFFF15C Interrupt control register UD1SIC R/W R/W - - 0xFFFFF15E Interrupt control register UD1RIC R/W R/W - - 0xFFFFF160 Interrupt control register UD1TIC R/W R/W - - 0xFFFFF162 Interrupt control register IIC0IC R/W R/W - - 740 User's Manual U18743EE1V2UM00 1 - 8 - Special Function Registers Table A-2 Appendix A Other special function registers (3/9) Address Register name Shortcut 0xFFFFF164 Interrupt control register ADIC 0xFFFFF166 Interrupt control register 0xFFFFF168 16 32 R/W R/W - - C0ERRIC R/W R/W - - Interrupt control register C0WUPIC R/W R/W - - 0xFFFFF16A Interrupt control register C0RECIC R/W R/W - - 0xFFFFF16C Interrupt control register C0TRXIC R/W R/W - - 0xFFFFF176 Interrupt control register KRIC R/W R/W - - 0xFFFFF178 Interrupt control register WTIIC R/W R/W - - 0xFFFFF17A Interrupt control register WTIC R/W R/W - - 0xFFFFF17E Interrupt control register FLIC R/W R/W - - 0xFFFFF180 Interrupt control register PIC8 R/W R/W - - 0xFFFFF182 Interrupt control register PIC9 R/W R/W - - 0xFFFFF184 Interrupt control register PIC10 R/W R/W - - 0xFFFFF190 Interrupt control register UD2SIC R/W R/W - - 0xFFFFF192 Interrupt control register UD2RIC R/W R/W - - 0xFFFFF194 Interrupt control register UD2TIC R/W R/W - - 0xFFFFF1FA In-service priority register ISPR R R - - 0xFFFFF1FC Command register PRCMD - W - - 0xFFFFF1FE Power save control register PSC R/W R/W - - 0xFFFFF200 ADC0 mode register 0 ADA0M0 R/W R/W - - 0xFFFFF201 ADC0 mode register 1 ADA0M1 R/W R/W - - 0xFFFFF202 ADC0 channel specification register ADA0S R/W R/W - - 0xFFFFF203 ADC0 mode register 2 ADA0M2 R/W R/W - - 0xFFFFF204 ADC0 Power fail comparison mode register ADA0PFM R/W R/W - - 0xFFFFF205 ADC0 Power fail comparison threshold value register ADA0PFT R/W R/W - - 0xFFFFF20C ADC0 conversion result register DD ADA0CRDD - - R - 0xFFFFF20D ADC0 conversion result register DDH ADA0CRDDH - R - - 0xFFFFF20E ADC0 conversion result register SS ADA0CRSS - - R - 0xFFFFF20F ADC0 conversion result register SSH ADA0CRSSH - R - - 0xFFFFF210 ADC0 conversion result register 0 ADA0CR0 - - R - 0xFFFFF211 ADC0 conversion result register 0H ADA0CR0H - R - - 0xFFFFF212 ADC0 conversion result register 1 ADA0CR1 - - R - 0xFFFFF213 ADC0 conversion result register 1H ADA0CR1H - R - - 0xFFFFF214 ADC0 conversion result register 2 ADA0CR2 - - R - 0xFFFFF215 ADC0 conversion result register 2H ADA0CR2H - R - - 0xFFFFF216 ADC0 conversion result register 3 ADA0CR3 - - R - 0xFFFFF217 ADC0 conversion result register 3H ADA0CR3H - R - - 0xFFFFF218 ADC0 conversion result register 4 ADA0CR4 - - R - 0xFFFFF219 ADC0 conversion result register 4H ADA0CR4H - R - - 0xFFFFF21A ADC0 conversion result register 5 ADA0CR5 - - R - 0xFFFFF21B ADC0 conversion result register 5H ADA0CR5H - R - - 0xFFFFF21C ADC0 conversion result register 6 ADA0CR6 - - R - User's Manual U18743EE1V2UM00 1 8 741 Appendix A Special Function Registers Table A-2 Other special function registers (4/9) Address Register name Shortcut 1 8 16 32 0xFFFFF21D ADC0 conversion result register 6H ADA0CR6H - R - - 0xFFFFF21E ADC0 conversion result register 7 ADA0CR7 - - R - 0xFFFFF21F ADC0 conversion result register 7H ADA0CR7H - R - - 0xFFFFF220 ADC0 conversion result register 8 ADA0CR8 - - R - 0xFFFFF221 ADC0 conversion result register 8H ADA0CR8H - R - - 0xFFFFF222 ADC0 conversion result register 9 ADA0CR9 - - R - 0xFFFFF223 ADC0 conversion result register 9H ADA0CR9H - R - - 0xFFFFF224 ADC0 conversion result register 10 ADA0CR10 - - R - 0xFFFFF225 ADC0 conversion result register 10H ADA0CR10H - R - - 0xFFFFF226 ADC0 conversion result register 11 ADA0CR11 - - R - 0xFFFFF227 ADC0 conversion result register 11H ADA0CR11H - R - - 0xFFFFF228 ADC0 conversion result register 12 ADA0CR12 - - R - 0xFFFFF229 ADC0 conversion result register 12H ADA0CR12H - R - - 0xFFFFF22A ADC0 conversion result register 13 ADA0CR13 - - R - 0xFFFFF22B ADC0 conversion result register 13H ADA0CR13H - R - - 0xFFFFF22C ADC0 conversion result register 14 ADA0CR14 - - R - 0xFFFFF22D ADC0 conversion result register 14H ADA0CR14H - R - - 0xFFFFF22E ADC0 conversion result register 15 ADA0CR15 - - R - 0xFFFFF22F ADC0 conversion result register 15H ADA0CR15H - R - - 0xFFFFF300 Key return mode register KRM R/W R/W - - 0xFFFFF308 Selector motion control register 0 SELCNT0 R/W R/W - - 0xFFFFF30C Selector motion control register 2 SELCNT2 R/W R/W - - 0xFFFFF30E Selector motion control register 3 SELCNT3 R/W R/W - - 0xFFFFF318 Noise elimination control register NFC R/W R/W - - 0xFFFFF340 OPS0 clock selection register OCKS0 R/W - - 0xFFFFF400 Port 0 P0 R/W R/W - - 0xFFFFF402 Port 1 P1 R/W R/W - - 0xFFFFF406 Port 3 P3 R/W - 0xFFFFF406 Port 3L P3L R/W R/W - - 0xFFFFF407 Port 3H P3H R/W R/W - - 0xFFFFF408 Port 4 P4 R/W R/W - - 0xFFFFF40A Port 5 P5 R/W R/W - - 0xFFFFF40E Port 7L P7L R/W R/W - - 0xFFFFF40F Port 7H P7H R/W R/W - - 0xFFFFF412 Port 9 P9 R/W - 0xFFFFF412 Port 9L P9L R/W R/W - - 0xFFFFF413 Port 9H P9H R/W R/W - - 0xFFFFF420 Port mode register 0 PM0 R/W R/W - - 0xFFFFF422 Port mode register 1 PM1 R/W R/W - - 0xFFFFF426 Port mode register 3 PM3 R/W - 0xFFFFF426 Port mode register 3L PM3L - - 742 User's Manual U18743EE1V2UM00 - - - - - - - R/W R/W Special Function Registers Table A-2 Appendix A Other special function registers (5/9) Address Register name Shortcut 0xFFFFF427 Port mode register3H PM3H 0xFFFFF428 Port mode register4 0xFFFFF42A 16 32 R/W R/W - - PM4 R/W R/W - - Port mode register5 PM5 R/W R/W - - 0xFFFFF42E Port mode register7L PM7L R/W R/W - - 0xFFFFF42F Port mode register7H PM7H R/W R/W - - 0xFFFFF432 Port mode register9 PM9 R/W - 0xFFFFF432 Port mode register9L PM9L R/W R/W - - 0xFFFFF433 Port mode register9H PM9H R/W R/W - - 0xFFFFF440 Port mode control register0 PMC0 R/W R/W - - 0xFFFFF442 Port mode control register1 PMC1 R/W R/W - - 0xFFFFF446 Port mode control register3 PMC3 R/W - 0xFFFFF446 Port mode control register3L PMC3L R/W R/W - - 0xFFFFF447 Port mode control register3H PMC3H R/W R/W - - 0xFFFFF448 Port mode control register4 PMC4 R/W R/W - - 0xFFFFF44A Port mode control register5 PMC5 R/W R/W - - 0xFFFFF44C Port mode control register6L PMC6L R/W R/W - - 0xFFFFF44D Port mode control register6H PMC6H R/W R/W - - 0xFFFFF44E Port mode control register7L PMC7L R/W R/W - - 0xFFFFF44F Port mode control register7H PMC7H R/W R/W - - 0xFFFFF452 Port mode control register9 PMC9 R/W - 0xFFFFF452 Port mode control register9L PMC9L R/W R/W - - 0xFFFFF453 Port mode control register9H PMC9H R/W R/W - - 0xFFFFF460 Port function control register0 PFC0 R/W R/W - - 0xFFFFF466 Port function control register3L PFC3L R/W R/W - - 0xFFFFF468 Port function control register4 PFC4 R/W R/W - - 0xFFFFF46A Port function control register5 PFC5 R/W R/W - - 0xFFFFF472 Port function control register9 PFC9 R/W - 0xFFFFF472 Port function control register9L PFC9L R/W R/W - - 0xFFFFF473 Port function control register9H PFC9H R/W R/W - - 0xFFFFF590 TAA0 control register 0 TAA0CTL0 R/W R/W - - 0xFFFFF591 TAA0 control register 1 TAA0CTL1 R/W R/W - - 0xFFFFF592 TAA0 I/O control register 0 TAA0IOC0 R/W R/W - - 0xFFFFF593 TAA0 I/O control register 1 TAA0IOC1 R/W R/W - - 0xFFFFF594 TAA0 I/O control register 2 TAA0IOC2 R/W R/W - - 0xFFFFF595 TAA0 option register 0 TAA0OPT0 R/W R/W - - 0xFFFFF596 TAA0 capture/compare register 0 TAA0CCR0 - - R/W - 0xFFFFF598 TAA0 capture/compare register 1 TAA0CCR1 - - R/W - 0xFFFFF59A TAA0 counter read buffer register TAA0CNT - - R - 0xFFFFF59C TAA0 I/O control register 4 TAA0IOC4 R/W R/W - - 0xFFFFF5A0 TAA1 control register 0 TAA1CTL0 R/W R/W - - 0xFFFFF5A1 TAA1 control register 1 TAA1CTL1 R/W R/W - - User's Manual U18743EE1V2UM00 1 - - - - 8 - - - - 743 Appendix A Special Function Registers Table A-2 Other special function registers (6/9) Address Register name Shortcut 0xFFFFF5A2 TAA1 I/O control register 0 TAA1IOC0 0xFFFFF5A3 TAA1 I/O control register 1 0xFFFFF5A4 16 32 R/W R/W - - TAA1IOC1 R/W R/W - - TAA1 I/O control register 2 TAA1IOC2 R/W R/W - - 0xFFFFF5A5 TAA1 option register 0 TAA1OPT0 R/W R/W - - 0xFFFFF5A6 TAA1 capture/compare register 0 TAA1CCR0 - - R/W - 0xFFFFF5A8 TAA1 capture/compare register 1 TAA1CCR1 - - R/W - 0xFFFFF5AA TAA1 counter read buffer register TAA1CNT - - R - 0xFFFFF5AC TAA1 I/O control register 4 TAA1IOC4 R/W R/W - - 0xFFFFF5AD TAA1 option register 1 TAA1OPT1 R/W R/W - - 0xFFFFF5B0 TAA2 control register 0 TAA2CTL0 R/W R/W - - 0xFFFFF5B1 TAA2 control register 1 TAA2CTL1 R/W R/W - - 0xFFFFF5B2 TAA2 I/O control register 0 TAA2IOC0 R/W R/W - - 0xFFFFF5B3 TAA2 I/O control register 1 TAA2IOC1 R/W R/W - - 0xFFFFF5B4 TAA2 I/O control register 2 TAA2IOC2 R/W R/W - - 0xFFFFF5B5 TAA2 option register 0 TAA2OPT0 R/W R/W - - 0xFFFFF5B6 TAA2 capture/compare register 0 TAA2CCR0 - - R/W - 0xFFFFF5B8 TAA2 capture/compare register 1 TAA2CCR1 - - R/W - 0xFFFFF5BA TAA2 counter read buffer register TAA2CNT - - R - 0xFFFFF5BC TAA2 I/O control register 4 TAA2IOC4 R/W R/W - - 0xFFFFF5C0 TAA3 control register 0 TAA3CTL0 R/W R/W - - 0xFFFFF5C1 TAA3 control register 1 TAA3CTL1 R/W R/W - - 0xFFFFF5C2 TAA3 I/O control register 0 TAA3IOC0 R/W R/W - - 0xFFFFF5C3 TAA3 I/O control register 1 TAA3IOC1 R/W R/W - - 0xFFFFF5C4 TAA3 I/O control register 2 TAA3IOC2 R/W R/W - - 0xFFFFF5C5 TAA3 option register 0 TAA3OPT0 R/W R/W - - 0xFFFFF5C6 TAA3 capture/compare register 0 TAA3CCR0 - - R/W - 0xFFFFF5C8 TAA3 capture/compare register 1 TAA3CCR1 - - R/W - 0xFFFFF5CA TAA3 counter read buffer register TAA3CNT - - R - 0xFFFFF5CC TAA3 I/O control register 4 TAA3IOC4 R/W R/W - - 0xFFFFF5CD TAA3 option register 1 TAA3OPT1 R/W R/W - - 0xFFFFF5D0 TAA4 control register 0 TAA4CTL0 R/W R/W - - 0xFFFFF5D1 TAA4 control register 1 TAA4CTL1 R/W R/W - - 0xFFFFF5D2 TAA4 I/O control register 0 TAA4IOC0 R/W R/W - - 0xFFFFF5D3 TAA4 I/O control register 1 TAA4IOC1 R/W R/W - - 0xFFFFF5D4 TAA4 I/O control register 2 TAA4IOC2 R/W R/W - - 0xFFFFF5D5 TAA4 option register 0 TAA4OPT0 R/W R/W - - 0xFFFFF5D6 TAA4 capture/compare register 0 TAA4CCR0 - - R/W - 0xFFFFF5D8 TAA4 capture/compare register 1 TAA4CCR1 - - R/W - 0xFFFFF5DA TAA4 counter read buffer register TAA4CNT - - R - 0xFFFFF5DC TAA4 I/O control register 4 TAA4IOC4 R/W R/W - - 0xFFFFF680 WTM R/W R/W - - 744 Watch Timer operation mode register User's Manual U18743EE1V2UM00 1 8 Special Function Registers Table A-2 Appendix A Other special function registers (7/9) Address Register name Shortcut 16 32 0xFFFFF690 TMM0 timer control register0 TM0CTL0 - - 0xFFFFF694 TMM0 compare register 0 TM0CMP0 - - R/W - 0xFFFFF6C0 Oscillation stabilization time select register OSTS - R/W - - 0xFFFFF6C1 PLL lockup time specification register PLLS - R/W - - 0xFFFFF6C2 Oscillation stabilization timer status register OSTC R R - - 0xFFFFF6D0 Watchdog Timer mode register 2 WDTM2 R/W R/W - - 0xFFFFF6D1 Watchdog Timer enable register WDTE R/W R/W - - 0xFFFFF700 Port 0 function control enhancing register PFCE0 R/W R/W - - 0xFFFFF706 Port 3 function control enhancing register L PFCE3L R/W R/W - - 0xFFFFF708 Port 4 function control enhancing register PFCE4 R/W R/W - - 0xFFFFF70A Port 5 function control enhancing register L PFCE5 R/W R/W - - 0xFFFFF712 Port 9 function control enhancing register PFCE9 R/W - 0xFFFFF712 Port 9 function control enhancing register L PFCE9L R/W R/W - - 0xFFFFF713 Port 9 function control enhancing register H PFCE9H R/W R/W - - 0xFFFFF802 System register SYS R/W R/W - - 0xFFFFF80c Internal oscillator mode register RCM R/W R/W - - 0xFFFFF820 Power save mode register PSMR R/W R/W - - 0xFFFFF824 Lock register LOCKR - - 0xFFFFF828 Processor clock control register PCC R/W R/W - - 0xFFFFF82C PLL control register PLLCTL R/W R/W - - 0xFFFFF82E CPU operating clock status register CCLS - - 0xFFFFF82F Programmable clock mode register PCLM R/W R/W - - 0xFFFFF860 System clock mode register MCM R/W R/W - - 0xFFFFF870 Clock Monitor mode register CLM R/W R/W - - 0xFFFFF888 Reset factor flag register RESF R/W R/W - - 0xFFFFF890 Low voltage detection register LVIM R/W R/W - - 0xFFFFF891 Low voltage detection level selection register LVIS R/W - - 0xFFFFF892 RAM data status register RAMS R/W R/W - - 0xFFFFF8B0 BRG0 prescaler mode register PRSM0 - R/W - - 0xFFFFF8B1 BRG0 prescaler compare register PRSCM0 - R/W - - 0xFFFFF9FC On-chip debug mode register OCDM R/W R/W - - 0xFFFFF9FE Peripheral emulation register 1 PEMU1 R/W R/W - - 0xFFFFFA00 UARTD0 control register 0 UD0CTL0 R/W R/W - - 0xFFFFFA01 UARTD0 control register 1 UD0CTL1 - R/W - - 0xFFFFFA02 UARTD0 control register 2 UD0CTL2 - R/W - - 0xFFFFFA03 UARTD0 option control register 0 UD0OPT0 R/W R/W - - 0xFFFFFA04 UARTD0 status register UD0STR R/W R/W - - 0xFFFFFA05 UARTD0 option control register 1 UD0OPT1 - R/W - - 0xFFFFFA06 UARTD0 receive data register UD0RX - R - - 0xFFFFFA07 UARTD0 transmit data register UD0TX - R/W - - 0xFFFFFA10 UARTD1 control register 0 UD1CTL0 R/W R/W - - User's Manual U18743EE1V2UM00 1 8 R/W R/W - R R - - R R 745 Appendix A Special Function Registers Table A-2 Other special function registers (8/9) Address Register name Shortcut 1 8 16 32 0xFFFFFA11 UARTD1 control register 1 UD1CTL1 - R/W - - 0xFFFFFA12 UARTD1 control register 2 UD1CTL2 - R/W - - 0xFFFFFA13 UARTD1 option control register 0 UD1OPT0 R/W R/W - - 0xFFFFFA14 UARTD1 status register UD1STR R/W R/W - - 0xFFFFFA15 UARTD1 option control register 1 UD1OPT1 - R/W - - 0xFFFFFA16 UARTD1 receive data register UD1RX - R - - 0xFFFFFA17 UARTD1 transmit data register UD1TX - R/W - - 0xFFFFFA20 UARTD2 control register 0 UD2CTL0 R/W R/W - - 0xFFFFFA21 UARTD2 control register 1 UD2CTL1 - R/W - - 0xFFFFFA22 UARTD2 control register 2 UD2CTL2 - R/W - - 0xFFFFFA23 UARTD2 option control register 0 UD2OPT0 R/W R/W - - 0xFFFFFA24 UARTD2 status register UD2STR R/W R/W - - 0xFFFFFA25 UARTD2 option control register 1 UD2OPT1 - R/W - - 0xFFFFFA26 UARTD2 receive data register UD2RX - R - - 0xFFFFFA27 UARTD2 transmit data register UD2TX - R/W - - 0xFFFFFC00 External interrupt falling edge specification register 0 INTF0 R/W R/W - - 0xFFFFFC02 External interrupt falling edge specification register 1 INTF1 R/W R/W - - 0xFFFFFC06 External interrupt falling edge specification register 3 INTF3 R/W - 0xFFFFFC06 External interrupt falling edge specification register 3L INTF3L R/W R/W - - 0xFFFFFC07 External interrupt falling edge specification register 3H INTF3H R/W R/W - - 0xFFFFFC08 External interrupt falling edge specification register 4 INTF4 R/W R/W - - 0xFFFFFC0C External interrupt falling edge specification register 6 INTF6 R/W - 0xFFFFFC0C External interrupt falling edge specification register 6L INTF6L R/W R/W - - 0xFFFFFC0D External interrupt falling edge specification register 6H INTF6H R/W R/W - - 0xFFFFFC10 External interrupt falling edge specification register 8 INTF8 R/W R/W - - 0xFFFFFC13 External interrupt falling edge specification register 9H INTF9H R/W R/W - - 0xFFFFFC20 External interrupt rising edge specification register 0 INTR0 R/W R/W - - 0xFFFFFC22 External interrupt rising edge specification register 1 INTR1 R/W R/W - - 0xFFFFFC26 External interrupt rising edge specification register 3 INTR3 R/W - 0xFFFFFC26 External interrupt rising edge specification register 3L INTR3L R/W R/W - - 0xFFFFFC27 External interrupt rising edge specification register 3H INTR3H R/W R/W - - 0xFFFFFC28 External interrupt rising edge specification register 4 INTR4 R/W R/W - - 0xFFFFFC2C External interrupt rising edge specification register 6 INTR6 R/W - 0xFFFFFC2C External interrupt rising edge specification register 6L INTR6L R/W R/W - - 0xFFFFFC2D External interrupt rising edge specification register 6H INTR6H R/W R/W - - 0xFFFFFC30 External interrupt rising edge specification register 8 INTR8 R/W R/W - - 0xFFFFFC33 External interrupt rising edge specification register 9H INTR9H R/W R/W - - 0xFFFFFC40 Pull-up resistor option register 0 PU0 R/W R/W - - 0xFFFFFC42 Pull-up resistor option register 1 PU1 R/W R/W - - 0xFFFFFC46 Pull-up resistor option register 3 PU3 R/W - 0xFFFFFC46 Pull-up resistor option register 3L PU3L - - 746 User's Manual U18743EE1V2UM00 - - - - - - - - - - R/W R/W Special Function Registers Table A-2 Appendix A Other special function registers (9/9) Address Register name Shortcut 0xFFFFFC47 Pull-up resistor option register 3H PU3H 0xFFFFFC48 Pull-up resistor option register 4 16 32 R/W R/W - - PU4 R/W R/W - - 0xFFFFFC4A Pull-up resistor option register 5 PU5 R/W R/W - - 0xFFFFFC4C Pull-up resistor option register 6 PU6 - - R/W - 0xFFFFFC52 Pull-up resistor option register 9 PU9 - - R/W - 0xFFFFFC52 Pull-up resistor option register 9L PU9L R/W R/W - - 0xFFFFFC53 Pull-up resistor option register 9H PU9H R/W R/W - - 0xFFFFFC73 Port 9 function control register H PF9H R/W R/W - - 0xFFFFFD00 CSIB0 control register 0 CB0CTL0 R/W R/W - - 0xFFFFFD01 CSIB0 control register 1 CB0CTL1 R/W R/W - - 0xFFFFFD02 CSIB0 control register 2 CB0CTL2 R/W R/W - - 0xFFFFFD03 CSIB0 status register CB0STR R/W R/W - - 0xFFFFFD04 CSIB0 receive data register CB0RX - - R - 0xFFFFFD04 CSIB0 receive data register L CB0RXL - R - - 0xFFFFFD06 CSIB0 transmit data register CB0TX - - R/W - 0xFFFFFD06 CSIB0 transmit data register L CB0TXL - R/W - - 0xFFFFFD10 CSIB1 control register 0 CB1CTL0 R/W R/W - - 0xFFFFFD11 CSIB1 control register 1 CB1CTL1 R/W R/W - - 0xFFFFFD12 CSIB1 control register 2 CB1CTL2 R/W - - 0xFFFFFD13 CSIB1 status register CB1STR R/W R/W - - 0xFFFFFD14 CSIB1 receive data register CB1RX - - R - 0xFFFFFD14 CSIB1 receive data register L CB1RXL - R - - 0xFFFFFD16 CSIB1 transmit data register CB1TX - - R/W - 0xFFFFFD16 CSIB1 transmit data register L CB1TXL - R/W - - 0xFFFFFD80 IIC0 shift register IIC0 - R/W - - 0xFFFFFD82 IIC0 control register IICC0 R/W R/W - - 0xFFFFFD83 IIC0 slave address register SVA0 R/W - - 0xFFFFFD84 IIC0 clock selection register IICCL0 R/W R/W - - 0xFFFFFD85 IIC0 function expansion register IICX0 R/W R/W - - 0xFFFFFD86 IIC0 state register IICS0 R/W R/W - - IICF0 R/W R/W - - 0xFFFFFD8A IIC0 flag register User's Manual U18743EE1V2UM00 1 - - 8 747 Appendix A 748 Special Function Registers User's Manual U18743EE1V2UM00 Appendix B Registers Access Times This chapter provides formulas to calculate the access time to registers, which are accessed via the peripheral I/O areas. All accesses to the peripheral I/O areas are passed over to the NPB bus via the VSB - NPB bus bridge BBR. Read and write access times to registers via the NPB depend on the register, the system clock VBCLK and the setting of the VSWC register. The CPU operation during an access to a register via the NPB depends also on the kind of peripheral I/O area: * Fixed peripheral I/O area During a read or write access the CPU operation stops until the access via the NPB is completed. * Programmable peripheral I/O area During a read access the CPU operation stops until the read access via the NPB is completed. During a write access the CPU operation continues operation, provided any preceded NPB access is already finished. If a preceded NPB access is still ongoing the CPU stops until this access is finished and the NPB is cleared. The following formulas are given to calculate the access times Ta, when the CPU reads from or writes to special function registers via the NPB bus. The access time depends * on the CPU system clock frequency fVBCLK * on the setting of the internal peripheral function wait control register VSWC, which determines the address set up wait SUWL = VSWC.SUWL and data wait VSWL = VSWC.VSWL (refer to "VSWC - Internal peripheral function wait control register" on page 302 for the correct values for a certain CPU system clock VBCLK) * for some registers on the clock frequency applied to the module Note "ru[...]" in the formulas mean "round up" the calculated value of the term in squared brackets. All formulas calculate the maximum access time. CPU access For calculating the access times for CPU accesses 1 VBLCK period time 1/ fVBCLK has to be added to the results of the formulas. B.1 Timer AA Register Access TAAnCCRm R User's Manual U18743EE1V2UM00 749 Appendix B Registers Access Times Formula * if TAAnCTL0.TAAnCE = 0: 1 Ta = ( SUWL + VSWL + 3 ) -----------------f VBCLK * if TAAnCTL0.TAAnCE = 1: 1 Ta = ( SUWL + 2 VSWL + 5 ) -----------------f VBCLK Access Formula W * if TAAnCTL0.TAAnCE = 0: 1 Ta = SUWL + VSWL + 3 -----------------fVBCLK * if TAAnCTL0.TAAnCE = 1: - continuous write 5 fVBCLK 1 T a = SUWL + VSWL + 3 + ru ------------------------------------------------ + 1 ( 2 + VSWL ) ----------------- f ( 2 + VSWL ) f TAA VBCLK - single write 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK Register Access Formula Access Formula TAAnIOC4 R 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK W * if TAAnCTL0.TAAnCE = 0: 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK * if TAAnCTL0.TAAnCE = 1: - continuous write 5 fVBCLK 1 T a = SUWL + VSWL + 3 + ru ------------------------------------------------ + 1 ( 2 + VSWL ) -----------------( 2 + VSWL ) f f TAA VBCLK - single write 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK 750 User's Manual U18743EE1V2UM00 Registers Access Times Register Access Formula Appendix B TAAnCNT R * if TAAnCTL0.TAAnCE = 0: 1 Ta = ( SUWL + VSWL + 3 ) -----------------f VBCLK * if TAAnCTL0.TAAnCE = 1: 1 Ta = ( SUWL + 2 VSWL + 5 ) -----------------f VBCLK Access W Formula 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK Register all other Access Formula fTAA R/W 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK The TAAn input clock can be selected from * SELCNT2.SELCNT2n = 0: fTAA = fXP1 * SELCNT2.SELCNT2n = 1: fTAA = fXP2 B.2 Timer M Register Access Formula all R/W 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK User's Manual U18743EE1V2UM00 751 Appendix B Registers Access Times B.3 Watchdog Timer 2 Register Access Formula WDTM2 W * if Watchdog Timer operating: 1 Ta = ( SUWL + 4 VSWL + 9 ) -----------------f VBCLK * if Watchdog Timer stopped: 1 Ta = ( SUWL + VSWL + 3 ) -----------------f VBCLK Access R Formula 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK Register all other Access Formula R/W 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK B.4 A/D Converter Register Access Formula Access R 2 f VBCLK 1 T a = SUWL + VSWL + 3 + ru ------------------------------------------------ + 1 ( 2 + VSWL ) -----------------( 2 + VSWL ) f XP1 f VBCLK W Formula 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK Register all other Access Formula 752 ADA0M0, ADA0CRm, ADA0CRmH, ADA0CRDD, ADA0CRDDH, ADA0CRDSS, ADA0CRSSH R/W 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK User's Manual U18743EE1V2UM00 Registers Access Times Appendix B B.5 I2C Bus Register Access IICSn R Formula 1 T a = ( SUWL + 3 VSWL + 7 ) -----------------f VBCLK Register all other Access Formula R/W 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK B.6 Asynchronous Serial Interface (UARTD) Register Access Formula all R/W 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK B.7 Clocked Serial Interface (CSIB) Register Access Formula all R/W 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK User's Manual U18743EE1V2UM00 753 Appendix B Registers Access Times B.8 CAN Controller Register Access CnMDATA[7:0]m R Formula Access 8-bit Write f VBCLK 5 ------------------ + 1 fCAN 1 ----------------------------------T a = SUWL + VSWL + 3 + ru ( 2 + VSWL ) -----------------( 2 + VSWL ) f VBCLK Formula Access 16-bit Write f VBCLK 3 ------------------ + 1 fCAN 1 T a = SUWL + VSWL + 3 + ru ------------------------------------ ( 2 + VSWL ) -----------------( 2 + VSWL ) f VBCLK Formula Register Access Formula Access Formula Register Access Formula fCAN f VBCLK 4 ------------------ + 1 fCAN 1 ----------------------------------T a = SUWL + VSWL + 3 + ru ( 2 + VSWL ) -----------------( 2 + VSWL ) f VBCLK CnRGPT, CnTGPT, CnLIPT, CnLOPT R 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK W f VBCLK 4 ------------------ + 1 fCAN 1 T a = SUWL + VSWL + 3 + ru ------------------------------------ ( 2 + VSWL ) -----------------( 2 + VSWL ) f VBCLK all other R/W f VBCLK 2 ------------------ + 1 fCAN 1 T a = SUWL + VSWL + 3 + ru ------------------------------------ ( 2 + VSWL ) -----------------( 2 + VSWL ) fVBCLK Refer to "Clock Generator" on page 159 for fCAN selection control. B.9 All other Registers Register Access Formula 754 all R/W 1 T a = ( SUWL + VSWL + 3 ) -----------------fVBCLK User's Manual U18743EE1V2UM00 Revision History Version Date Document number Description 1.0 August 2007 U18743EE1V0UM00 Initial release 1.1 April 2008 U18743EE1V1UM00 Update 1.2 June 2008 U18743EE1V2UM00 Update The following revision list shows all functional changes compared to the manual version U18743EE1V1UM00 (published in April 2008). Chapter Page Description 7 265 Corrected number of writable bytes in flash memory. 9 295 Added chapter 'Bus Control Unit' 24 735 Added SSCG to Fx3-L vs Fx3 difference list User's Manual U18743EE1V2UM00 755 756 User's Manual U18743EE1V2UM00 Index (ADAnCRSS) 677 AVSS A/D conversion diagnostic registers (ADAnCRSSH) 677 A A/D Converter 663 Basic operation 680 Cautions 694 Configuration 665 Control registers 667 How to read A/D Converter characteristics table 696 Operation mode 683 Power-fail compare mode 688 Trigger mode 681 ADAnCRDD 676 ADAnCRDDH 676 ADAnCRm 674 ADAnCRmH 674 ADAnCRSS 677 ADAnCRSSH 677 ADAnM0 667 ADAnM1 669 ADAnM2 671 ADAnPFM 678 ADAnPFT 679 ADAnS 672 ADC (A/D Converter) 663 ADC channel specification register (ADAnS) 672 ADC mode register 0 (ADAnM0) 667 ADC mode register 1 (ADAnM1) 669 ADC mode register 2 (ADAnM2) 671 ADC Power-fail compare mode register (ADAnPFM) 678 ADC Power-fail compare threshold value register (ADAnPFT) 679 ADC result registers (ADAnCRm) 674 ADC result registers H (ADAmCRmH) 674 Address space CPU 147 Data space 149 Images 148 Physical 147 Program space 149 ADIC 237 Analog filtered inputs 126 Asynchronous Serial Interface see UARTD AVREF A/D conversion diagnostic registers (ADAnCRDD) 676 AVREF A/D conversion diagnostic registers (ADAnCRDDH) 676 AVSS A/D conversion diagnostic registers User's Manual U18743EE1V2UM00 B Baud rate generator UARTD 419 BCU (Bus Control Unit) 295 BCU registers 301 Boundary operation conditions 299 BPC 301 Buffer diagrams 47 Bus and memory control Registers 301 Bus control 295 Bus properties 299 Bus access 299 Endian format 299 C C0ERRIC 237 C0RECIC 237 C0TRXIC 237 C0WUPIC 237 CALLT base pointer (CTBP) 145 CAN (Controller area network) 527 CAN Controller 527 Baud rate settings 629 Bit set/clear function 560 Configuration 530 Connection with target system 552 Control registers 562 Diagnosis functions 624 Functions 541 Initialization 598 Internal registers 553 Interrupt function 623 Message reception 602 Message transmission 610 Operation 637 Overview of functions 529 Power saving modes 618 Register access type 555 Register bit configuration 557 Special operational modes 624 Time stamp function 628 Transition from initialization mode to operation mode 600 CAN protocol 531 CANn global automatic block transmission control register (CnGMABT) 565 757 Index CANn global automatic block transmission delay register (CnGMABTD) 567 CANn global clock selection register (CnGMCS) 564 CANn global control register (CnGMCTRL) 562 CANn message configuration register m (CnMCONFm) 592 CANn message control register m (CnMCTRLm) 595 CANn message data byte register (CnMDATAxm) 589 CANn message data length register m (CnMDLCm) 591 CANn message ID register m (CnMIDLm, CnMIDHm) 594 CANn module bit rate prescaler register (CnBRP) 580 CANn module bit rate register (CnBTR) 581 CANn module control register (CnCTRL) 570 CANn module error counter register (CnERC) 576 CANn module information register (CnINFO) 575 CANn module interrupt enable register (CnIE) 577 CANn module interrupt status register (CnINTS) 579 CANn module last error information register (CnLEC) 574 CANn module last in-pointer register (CnLIPT) 582 CANn module last out-pointer register (CnLOPT) 584 CANn module mask control register (CnMASKaL, CnMASKaH) 568 CANn module receive history list register (CnRGPT) 583 CANn module time stamp register (CnTS) 587 CANn module transmit history list register (CnTGPT) 585 CB0RIC 237 CB0TIC 237 CB1RIC 237 CB1TIC 237 CBnCTL0 430 CBnCTL1 432 CBnCTL2 433 CBnRX 429 CBnSTR 435 CBnTX 429 CCLS 168 CLKOUT Function 215 Clock Generator 159 758 User's Manual U18743EE1V2UM00 General registers 168 Operation 191 PLL related registers 178 Registers 166 Start conditions 165 Clock Monitor 163 Control registers 184 Operation 217 Clock operation control settings 191 Clock signals summary 163 Clocked Serial Interface see CSIB Clocks CPU 161 for peripherals 162 in power save modes 211 Special clocks 162 CnBRP 580 CnBTR 581 CnCTRL 570 CnERC 576 CnGMABT 565 CnGMABTD 567 CnGMCS 564 CnGMCTRL 562 CnIE 577 CnINFO 575 CnINTS 579 CnLEC 574 CnLIPT 582 CnLOPT 584 CnMASKaH 568 CnMASKaL 568 CnMCONFm 592 CnMCTRLm 595 CnMDATAxm 589 CnMDLCm 591 CnMIDHm 594 CnMIDLm 594 CnRGPT 583 CnTGPT 585 CnTS 587 Command register (PRCMD) 157 CPU Address space 147 Clocks 161 Memory 151 Operation modes 146 Register set 137 Write protected registers 155 Index CPU operation clock status register (CCLS) 168 CSIB Configuration 428 Control registers 430 Operation 436 Operation flow 449 Output pins 448 CSIB (Clocked Serial Interface) 427 CSIB transmit data register (CBnTX) 429 CSIBn control register 0 (CBnCTL0) 430 CSIBn control register 1 (CBnCTL1) 432 CSIBn control register 2 (CBnCTL2) 433 CSIBn receive data register (CBnRX) 429 CSIBn status register (CBnSTR) 435 CTBP 145 CTPC 140 CTPSW 143 Flash memory 259 Self-programming 277 Flash programmer Communication mode 267 Pin connection 269 Flash programming Mode 146 FLIC 237 fPLLI 161 fPLLO 161 G General purpose registers (r0 to r31) 138 Global pointer 138 H HALT Mode 197 I D Data address space Recommended use 154 Data space 149 DBPC 140 DBPSW 143 Debug function (on-chip) 723 Code protection 289 Restrictions and Cautions 734 Debug Trap 251 Differences Fx3-L to Fx3 735 Digital noise filter control register (NFC) 128 Digitally filtered inputs 127 E ECCDIC 237 ECR 144 EIPC 140 EIPSW 143 Element pointer 138 Exception status flag (EP) 249 Exception trap 249 External interrupt falling edge specification register (INTFm) 244 External interrupt rising edge specification register (INTRm) 244 External reset 710 F FEPC 140 FEPSW 143 Fixed peripheral I/O area 152, 296 Flash area 151 User's Manual U18743EE1V2UM00 I2C bus 457 Acknowledge signal 483 Address match detection method 507 Arbitration 509 Bus Mode Functions 480 Cautions 511 Communication operations 512 Configuration 458 Control registers 462 Definitions and control methods 481 Error detection 507 Extension code 508 Interrupt request signal (INTIICn) generation timing and wait control 506 Interrupt Request Signals (INTIICn) 488 Interrupt request signals (INTIICn) 488 Pin configuration 457 Pin functions 480 Stop condition 485 Timing of data communication 519 Transfer direction specification 483 Wait signal 486 Wakeup function 510 Idle pins Recommended connection 131 IDLE1 mode 199 IDLE2 mode 201 IIC clock select registers (IICCLn) 472 IIC control registers (IICCn) 463 IIC division clock select registers (OCKSn) 474 IIC flag registers (IICFn) 470 IIC function expansion registers (IICXn) 473 759 Index IIC shift registers (IICn) 479 IIC status registers (IICSn) 467 IIC0IC 237 IICCLn 472 IICCn 463 IICFn 470 IICn 479 IICSn 467 IICXn 473 Images in address space 148 IMRn 240 In-service priority register (ISPR) 242 INTC (Interrupt Controller) 221 Internal flash area 151 Internal oscillator 160 Internal oscillator mode register (RCM) 177 Internal peripheral function wait control register (VSWC) 302 Internal RAM area 151 Internal RAM data status register (RAMS) 717 Interrupt Maskable 230 Non-maskable 224 Processing (multiple interrupts) 252 Response time 254 Interrupt control registers 237 Interrupt Controller 221 Debug trap 251 Edge detection configuration 244 Exception trap 249 Periods in which interrupts are not acknowledged 255 Software exception 247 Interrupt mask registers IMRn 240 Interrupt/exception source register (ECR) 144 INTFm 244 INTRm 244 ISPR 242 K Key Interrupt Function 257 Cautions 258 Control register 258 Key return mode register (KRM) 258 KRIC 237 KRM 258 L Link pointer 138 LOCKR 178 Low voltage detection level selection register 760 User's Manual U18743EE1V2UM00 (LVIS) 716 Low voltage detection register (LVIM) 714 Low Voltage Detector 713 Configuration 713 Operation 719 Registers 714 LVIHIC 237 LVILIC 237 LVIM 714 LVIS 716 M Main oscillator 160 Main system clock mode register (MCM) 169 Maskable interrupt control registers (xxICn) 237 Maskable interrupt status flag (ID) 243 Maskable interrupts 230 MCM 169 Memory Areas 151 Modified usage of TAAnCTL0 during TAA operation. 314 N NFC 128 Noise elimination Pin input 126 Non-maskable interrupts 224 Normal operation mode 146 N-Wire Code protection 289 Connection to emulator 730 Controlling the interface 726 Emulator 723 Enabling methods 728 Security function 725 O OCDM 42, 726 OCKSn 474 On-chip debug mode register (OCDM) 42, 726 Open drain configuration 46 Operation modes Flash programming mode 146 Normal operation mode 146 Option Bytes 188 Oscillation stabilization time select register (OSTS) 171 Oscillation stabilization timer status register (OSTC) 170 Oscillators Index Internal oscillator 160 Main oscillator 160 Sub oscillator 160 OSTC 170 OSTS 171 P Package pins assignment 132 PC 140 PC saving registers 140 PCC 173 PCLM 176 PEMU1 718 Peripheral area selection control register (BPC) 301 Peripheral clocks 162 Peripheral emulation register 1 (PEMU1) 718 Peripheral I/O area 296 fixed 152, 296 programmable 153, 297 PFCEn 41 PFCn 40 PFn 46 Phase Locked Loop (PLL) 161 Physical address space 147 PIC0 237 PIC1 237 PIC10 237 PIC2 237 PIC3 237 PIC4 237 PIC5 237 PIC6 237 PIC7 237 PIC8 237 PIC9 237 Pin functions 31 After reset/power save modes 130 List 104 Unused pins 131 PLL 161 Control 215 PLL control register (PLLCTL) 179 PLL lock status register (LOCKR) 178 PLL lockup time specification register (PLLS) 180 PLLCTL 179 PLLS 180 PMCn 38 PMn 39 Pn 43 User's Manual U18743EE1V2UM00 POC (Power-On Clear) 708 Port function control expansion register (PFCEn) 41 Port function control register (PFCn) 40 Port function register (PFn) 46 Port groups 32 Configuration 51 Configuration registers 36 List 100 Port mode control register (PMCn) 38 Port mode register (PMn) 39 Port pull-up resistor option register (PUn) 45 Port register (Pn) 43 Power save control register (PSC) 181 Power save mode control register (PSMR) 182 Power save modes Activation 213 Description 196 Overview 164 Power Supply Scheme 701 Description 702 Voltage regulators 703 Power-on Clear Reset 708 PPA (programmable peripheral I/O area) 297 PRCMD 157 PRDSELH - Product selection code register high 288 Prescaler3 216 Prescaler3 compare register (PRSCM0) 183 Prescaler3 control registers 183 Prescaler3 mode register (PRSM0) 183 Processor clock control register (PCC) 173 Program counter (PC) 140 Program space 149 Program status word (PSW) 141 Programmable clock mode register (PCLM) 176 Programmable peripheral I/O area 153, 297 PRSCM0 183 PRSM0 183 PSC 181 PSMR 182 PSW 141 PSW saving registers 143 PUn 45 R RAM area 151 RAMS 717 RCM 177 regID (system register number) 139 761 Index Reset 705 At power-on 708 By clock monitor 711 By Watchdog Timer 711 External reset 710 Hardware status after reset 706 Register status after reset 707 Registers 712 Reset source flag register (RESSTAT) 712 RESSTAT 712 S Saturated operation instructions 142 SELCNT0 185, 312 SELCNT2 186 SELCNT3 187, 313 SELCNTx 185, 312 Selector control register 0 312 Selector control register 0 (SELCNT0) 185 Selector control register 2 (SELCNT2) 186 Selector control register 3 313 Selector control register 3 (SELCNT3) 187 Selector control registers (SELCNTx) 185, 312 SFR (special function register) 737 Slave address registers (SVAn) 479 Software exception 247 Special clocks 162 Special function registers (list) 737 Stack pointer 138 Stand-by control 163 Registers 181 STOP mode 204 Sub IDLE mode 208 Sub oscillator 160 Subclock mode 207 SVAn 479 SYS 157 System register (SYS) 157 System register set 139 T TAA capture/compare register 0 (TAAnCCR0) 309 TAA capture/compare register 1 (TAAnCCR1) 310 TAA control register 0 (TAAnCTL0) 314 TAA counter read buffer register (TAAnCNT) 311 TAA dedicated I/O control register 0 (TAAnIOC0) 318 TAA dedicated I/O control register 1 (TAAnIOC1) 319 762 User's Manual U18743EE1V2UM00 TAA I/O control register 2 (TAAnIOC2) 321 TAA I/O control register 4 (TAAnIOC4) 323 TAA option register 0 (TAAnOPT0) 324 TAA option register 1 (TAAnOPT1) 325 TAA timer control register 1 (TAAnCTL1) 316 TAA0CCIC0 237 TAA0CCIC1 237 TAA0OVIC 237 TAA1CCIC0 237 TAA1CCIC1 237 TAA1OVIC 237 TAA2CCIC0 237 TAA2CCIC1 237 TAA2OVIC 237 TAA3CCIC0 237 TAA3CCIC1 237 TAA3OVIC 237 TAA4CCIC0 237 TAA4CCIC1 237 TAA4OVIC 237 TAAnCCR0 309 TAAnCCR1 310 TAAnCNT 311 TAAnCTL0 314 TAAnCTL1 316 TAAnIOC0 318 TAAnIOC1 319 TAAnIOC2 321 TAAnIOC4 323 TAAnOPT0 324 TAAnOPT1 325 Text pointer 138 Timer M 371 Configuration 371 Operation 374 Registers 372 Timer M0 compare register 0 (TM0CMP0) 372 Timer M0 control register 0 (TM0CTL0) 373 TM0CMP0 372 TM0CTL0 373 TM0EQIC0 237 U UARTD Cautions 426 Dedicated baud rate generator 419 Interrupt request signals 403 Operation 404 UARTDn control register 0 (UDnCTL0) 395 UARTDn control register 1 (UDnCTL1) 420 Index UARTDn control register 2 (UDnCTL2) 421 UARTDn option control register 0 (UDnOPT0) 397 UARTDn option control register 1 (UDnOPT1) 399 UARTDn receive data register (UDnRX) 402 UARTDn receive shift register 393 UARTDn status register (UDnSTR) 400 UARTDn transmit data register (UDnTX) 402 UARTDn transmit shift register 394 UD0RIC 237 UD0SIC 237 UD0TIC 237 UD1RIC 237 UD1SIC 237 UD1TIC 237 UD2RIC 237 UD2SIC 237 UD2TIC 237 UDnCTL0 395 UDnCTL1 420 UDnCTL2 421 UDnOPT0 397 UDnOPT1 399 UDnRX 402 UDnSTR 400 UDnTX 402 Z Zero register 138 V VSWC 302 W Watch Dog Timer Clock 215 Watch Timer Functions Configuration 380 Control Registers 381 Operation 382 Watch Timer Functions 379 Watch timer operation mode register (WTM) 381 Watchdog Timer 2 385 Configuration 386 Control Registers 387 Watchdog timer 2 mode register (WDTM2) 387 Watchdog timer enable register (WDTE) 389 WDTE 389 WDTM2 387 Write protected registers 155 WTIC 237 WTIIC 237 WTM 381 User's Manual U18743EE1V2UM00 763 764 User's Manual U18743EE1V2UM00