AN1365 Recommended Usage of Microchip Serial RTCC Devices Author: Martin Bowman Microchip Technology Inc. INTRODUCTION Many embedded systems require some form of accurate timekeeping. There are a growing number of applications that require an external Real-Time Clock/ Calendar (RTCC) and higher integration of external peripheral components into the RTCC. In order to achieve a highly robust and repeatable system, the designer must consider the rest of the system components including pull-up resistor values and the crystal selection. There are a number of situations that can result in less than optimal operation, many of which are easy mistakes that are avoidable with some initial knowledge. These are discussed in this application note. This application note provides assistance and guidance in using the Microchip RTCC family of devices. This application note covers both the I2C™ (MCP794XX) and SPI (MCP795XXX) family of devices. These recommendations are not meant as requirements, however, their adoption will lead to a more robust overall design. The following topics are discussed: • • • • • • • Basic Design Considerations VCC Supply Backup Supply options Input Pins Output Pins Crystal Selection Recommended Schematics (Appendix B-D) All of the recommended practices that are detailed in this document are used on the RTCC PICtail™ daughter boards available from Microchip. Appendix B: “Recommended Connections for MCP794XX Series Devices” shows the suggested connections for using the Microchip I2C MCP794XX RTCC family. Appendix C: “Recommended Connections for MCP795XX Series Devices” and Appendix D: “Recommended Connections for MCP795WXX Series Devices” show similar schematic for the SPI RTCC devices. The basis for these connections will be explained in the following sections. 2010-2013 Microchip Technology Inc. POWER SUPPLY Microchip I2C RTCC devices feature a robust serial communication protocol that guards against unintentional writes and data corruption while power is within normal operating levels. The Microchip Serial RTCC devices operate over a wide voltage range. Two power supplies are required for full device operation: • Main VCC – Required for full Read/Write functionality and clock/calendar operation. • VBAT Supply – Required to maintain the clock/ calendar during the time when VCC is not present. Please refer to the device data sheet for voltage range information. Additional information regarding the VBAT supply is provided later in this text. As is shown in the schematics in Appendix B through D, a decoupling capacitor (typically 0.1 F) should be used to help filter out noise on VCC. Power-Up On power-up, VCC should always begin at 0V and rise to its normal operating voltage to ensure a proper Power-on Reset. VCC should not linger at an ambiguous voltage (i.e., below the minimum operating voltage). However, if VCC happens to fall below the minimum retention voltage for the device (see data sheet DC Characteristics), it is recommended that VCC be brought down fully to 0V before returning to normal operating level. This will help to ensure that the device is reset properly. Furthermore, if the microcontroller features a Brownout Reset with a threshold higher than that of the RTCC, bringing VCC down to 0V will allow both devices to be reset together. Otherwise, the microcontroller may reset during communication while the RTCC is still in an operational condition. VCC Ramp Rates The Microchip RTCC family integrates a battery switch over circuit to maintain the time and also the contents of the SRAM during the time when VCC is below the VTRIP threshold as defined in the data sheet. Due to the fact that the circuit operates at a very low current level, care should be exercised to ensure that the rise and fall times listed in the data sheet are met. DS00001365D-page 1 MCP794XX/MCP795XXX Many applications will meet these requirements simply based on the capacitance on the VCC lines and also the output impedance of the power supply circuit and the PCB copper resistance. FIGURE 1: The following data sheet timing specifications should be met. • TFvcc – VTRIP(max) to VTRIP(min) • TRvcc – VTRIP(min) to VTRIP(max) VTRIP GRAPH VCC VTRIP(max) VTRIP(min) Internal Switch to VBAT Internally, the RTCC will switch to the VBAT supply when VCC drops to the VTRIP voltage detailed in the data sheet. Failure of VCC During a Read During a read of the RTCC registers, SRAM or EEPROM, if the VCC supply drops, the device will continue to operate as per the device data sheet and communication is still possible with the device until VCC reaches the VBAT trip point. Failure of VCC During an EEPROM Write During the time that data is being written to the EEPROM or unique ID locations, VCC should remain above the minimum operating voltage – typically 1.8V. If at any time VDD drops below this minimum voltage but remains above the VBAT switch over voltage (VTRIP as specified in the device data sheet) then care should be taken to ensure that the data written to the device is free from errors by verifying the contents of the memory written. If at any time the VCC voltage drops below 1.5V (VBAT switch over) then the I2C and SPI interface is disabled and any writes that are in process will be terminated. It is recommended that, after such a condition, the EEPROM locations that were being written are verified. DS00001365D-page 2 TRVCC TFVCC Time-stamp (power loss) Time-stamp (power restore) Failure of VCC During an SRAM or RTCC Write SRAM and RTCC writes are possible when VCC is dropping until the VBAT trip point is reached. It is not recommended to communicate during this time and all I2C and SPI communication should be stopped as soon as possible if the system is able to detect a power-fail condition. VBAT Selection This is not applicable to the MCP7940M device. The external VBAT pin supplies power to maintain the RTCC and also the SRAM during a VCC power fail. If this function is not required, then the VBAT pin should be connected to GND. Connecting this pin to GND will result in the lowest current configuration. The supported voltage on this pin is from 1.3V to 5.5V. The internal circuit will switch to the VBAT voltage when VCC drops to 1.5V (data sheet parameter VTRIP). The RTCC and SRAM will continue to be maintained until the VBAT voltage drops to 1.3V. The Microchip RTCC devices will support both primary backup supplies (battery etc.) and also rechargeable solutions (NiCad, Super Cap, etc). When using any supply it is recommended to include a 1K series resistor between the supply and the VBAT pin and a 100pF capacitor between VBAT pin and GND. Additionally, a series diode is recommended when using a nonrechargeable supply to eliminate any current flowing into the cell during a device failure. 2010-2013 Microchip Technology Inc. MCP794XX/MCP795XXX When using a rechargeable solution, additional components will be required to support a charge current to maintain the voltage on the battery/capacitor. Care should be exercised to ensure that the backup supply cannot power the VCC supply during a main supply failure, this is accomplished using a diode in series with the current limit resistor. Figure 2 shows a typical schematic for using a supercap, the same schematic would also apply to a rechargable battery. FIGURE 2: SUPERCAP VCC EVHS and EVLS These pins are only available on the following device: • MCP795WXX – 14-pin SPI RTCC Family The High-Speed Event (EVHS) detect and Low-Speed Event (EVLS) detect are digital input pins and require either a pull-up or pull-down resistor. These pins are used as the input to the Event Detection circuit. If this feature is not being used in the application then these inputs should be connected to GND. SERIAL COMMUNICATION PINS SPI Communication Shottky Diode Sized to limit charge current and charge time The MCP795XXX supports the industry standard SPI bus protocol using the SCK, SD, SO and CS Lines. 1K Ohms Backup Capacitor VBAT 100pF RTCC The CS line must be brought low at the start of a command and raised at the end of the command. The CS line being raised completes the command and performs the write cycle for a nonvolatile memory write. The CS line should not toggle during the command sequence, as raising the CS line before the command is complete terminates the current command. A pull up is recommended on CS to ensure that the RTCC powers up in an unselected state. I2C Communication UL Considerations One of the requirements for UL approval and certification is related to the VBAT supply. If a lithium primary cell is used (CR2032 or similar), then there are reverse leakage currents that have to be taken into consideration. By using the recommended low voltage drop (Schottky) diode in series with the lithium backup battery, this issue is limited. In addition to the recommended diode and series resistor, internally the VBAT/VCC switch over circuit has been designed such that in the event of a catastrophic failure of the device, the switch will fail in a safe manner and not conduct from VCC to VBAT. INPUT-ONLY PINS It is never good practice to leave a digital input pin floating. This can cause an elevated standby current as well as undesired functionality. If a pin is left floating, it can float either low or high. The final logic state is dependent upon a number of factors, including noise in the system and capacitive coupling. Because of this, the level seen by the input circuitry is relatively random and likely to change during operation. This applies to the EVHS and EVLS pins detailed below. 2010-2013 Microchip Technology Inc. The MCP794XX supports an I2C-compatible serial interface. To follow the I2C specification, both the Serial Data (SDA) and Serial Clock (SCL) lines require a pull up to VCC. As the MCP794XX is designed to run at a maximum of 400 kHz, suggested values at this speed for both SCL and SDA are 2.2K Ohms at 5.5V. Application Note AN1028, “Recommended Usage of Microchip I2C™ Serial EEPROM Devices”, on the Microchip web site, provides additional guidance for the use and implementation of the I2C bus. OUTPUT-ONLY PINS MFP Pin This Pin is available on the following devices: • MCP794XX – I2C RTCC Family • MCP795XX – 10-pin SPI RTCC Family The multi-function pin (MFP) is used for a number of functions when enabled by the RTCC registers. As this pin is an open-drain output, a pull up is required to VCC (it is not recommended to use a pull up to the VBAT timekeeping supply). This pin can sink a maximum of 10mA. DS00001365D-page 3 MCP794XX/MCP795XXX FIGURE 3: MFP DIAGRAM V CC The WDO and IRQ pins are open-drain and are capable of sinking 10mA (Please refer to the DC Characteristics in the data sheet). A pull-up to VCC is required on these pins. The WDO and IRQ pins are used as the output from the on-board watchdog timer and the alarm interrupt event. RTCC D evice M FP P IN If the WDO and IRQ pins are not used they can be left floating. CRYSTAL SELECTION The MCP794XX and MCP795XXX have been designed to operate with a standard 32.768 kHz tuning fork crystal with external loading capacitors. Suitable crystals have a load capacitance of 6-9pF. It is not recommended using crystals with a load capacitance of 12.5pF. The MFP pin is used for the following operation when VCC is present on the device: • Alarm output – an active alarm generated from one of the programmable alarms will assert this line (pull the line low). The line can be wire OR’d to other open-drain signals to drive a single MCU IRQ line. • General purpose output – can be used as an additional I/O line under the control of the MCU. • Output a clock signal – can be used to output a frequency derived from the 32.768 kHz crystal. As this is an open drain, the size of the pull-up resistor and the bus capacitance of that line will determine the rise and fall time of the signal. For a list of tested crystals and suggested load capacitors, please refer to AN1519, “Recommended Crystals for Microchip Stand-Alone Real-Time Clock/Calendar Devices”. One of the key points in selecting a crystal and load capacitors is the load capacitance of the crystal. A crystal with a specified CL of 7pF will not operate at the desired frequency using two 7pF capacitors. The CL is the effective load capacitance, which includes the physical capacitors, pin capacitance and stray board capacitance. When calculating the effective load capacitance, Equation 1 can be used: EQUATION 1: When VCC is removed and the device is running from the backup supply, VBAT, the only functions that are active on this pin are the alarms; all other functions are disabled until VCC is restored. CLKOUT Pin Cx2 C x1 CL = ------------------------- + C stray C x2 + C x1 FIGURE 4: OSCILLATOR DIAGRAM This pin is only available on the following device: CX1 • MCP795WXX – 14-Pin SPI RTCC Family The CLKOUT is a push/pull output that can produce a square-wave that is derived from the crystal and onboard oscillator. Please consult the device data sheet for the source/ sink specifications of this pin. If this pin is used to provide a clock source to another device, care must be taken to ensure that the load of the driven device does not exceed the drive capability of this pin. If this pin is not used it can be left floating; do not connect to VCC or GND, as this is a digital output. WDO and IRQ X1 RTCC X2 CX2 The recommended board layout for the oscillator area for the MCP794XX (also applicable to the MCP795XXX) is shown in Figure 4. These pins are only available on the following device: • MCP795WXX – 14-pin SPI RTCC Family DS00001365D-page 4 2010-2013 Microchip Technology Inc. MCP794XX/MCP795XXX Oscillator Layout SUMMARY Given that the oscillator is designed for minimum operating current, care must be taken when laying out the PCB traces. This is discussed below. This application note illustrates recommended techniques for increasing design robustness when using the Microchip family of RTCC’s. These recommendations fall directly in line with how Microchip designs, manufactures, qualifies and tests its RTCC devices and will allow the devices to operate within the data sheet parameters. It also serves to explain in detail some of the features of the device and makes the user aware of any potential pitfalls that may be encountered. • Keep traces as short as possible to the crystal and the load capacitors. Minimizing the length is important to keep stray capacitance to a minimum. For that reason, it is not recommended to use any kind of a socket, or package interposer when developing with the RTCC devices. An alternative that can be used is the RTCC PICtail daughter board. • Use a ground ring. During the PCB layout, a ground ring should be placed around both the crystal and also the X1 and X2 pins (pins 1, 2) on the device. This ground ring should be connected to a low-impedance ground connection. A recommended layout is shown in Figure 5. In the PCB layout example below, C2 and C3 are the load capacitors CX1 and CX2. FIGURE 5: This document should be read in conjunction with the following additional resources: • Device Data Sheet • AN1491, “Configuring the MCP794XX RTCC Family” • AN1496, “Debugging Stand-Alone Real-Time Clock/Calendar-Based Applications” • AN1519, “Recommended Crystals for Microchip Stand-Alone Real-Time Clock/Calendar Devices” CRYSTAL LAYOUT (MCP794XX SHOWN) It is recommended that the final application be tested with the chosen crystal and capacitor across all environmental and operating conditions. The Gerber files for the PICtail daughter board are available on the web site following the link on www.microchip.com/rtcc. 2010-2013 Microchip Technology Inc. DS00001365D-page 5 MCP794XX/MCP795XXX APPENDIX A: REVISION HISTORY Revision C (11/2011) Changed part number from MCP795XX MCP795XXX; Added Revision History. to Revision D (03/2013) Document format changed. Added additional information for crystal selection. Removed incorrect references. DS00001365D-page 6 2010-2013 Microchip Technology Inc. MCP794XX/MCP795XXX VCC 10K VCC 2K VCC RECOMMENDED CONNECTIONS FOR MCP794XX SERIES DEVICES 2K APPENDIX B: 6 5 MCU 8 X1 SCL SDA X2 MCP794XX 7 VBAT CX1 1 32.768 kHz 2 CX2 3 1K Diode MFP 4 2010-2013 Microchip Technology Inc. .1µF 100pF DS00001365D-page 7 MCP794XX/MCP795XXX VCC 10K VCC RECOMMENDED CONNECTIONS FOR MCP795XX SERIES DEVICES MCU VCC 10K APPENDIX C: 4 8 7 6 9 .1µF 10 X1 CS SCK SO SI X2 VBAT CX1 1 32.768 kHz 2 CX2 3 1K Diode MFP 5 100pF MCP795XX DS00001365D-page 8 2010-2013 Microchip Technology Inc. MCP794XX/MCP795XXX APPENDIX D: VCC RECOMMENDED CONNECTIONS FOR MCP795WXX SERIES DEVICES VCC VCC 10K x 3 .1µF 14 MCU 6 10 8 9 X1 CS SCK SO SI X2 CX1 1 32.768 kHz 2 CX2 EVHS 12 13 CLKOUT EVLS 11 4 WDO VBAT 3 5 IRQ 7 1K Diode 100pF MCP795WXX Note: Both the EVHS and EVLS should be externally connected to either pull-up or pull-down resistors depending on the polarity of the trigger. 2010-2013 Microchip Technology Inc. DS00001365D-page 9 MCP794XX/MCP795XXX NOTES: DS00001365D-page 10 2010-2013 Microchip Technology Inc. Note the following details of the code protection feature on Microchip devices: • Microchip products meet the specification contained in their particular Microchip Data Sheet. • Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions. • There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property. • Microchip is willing to work with the customer who is concerned about the integrity of their code. • Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.” Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act. Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights. Trademarks The Microchip name and logo, the Microchip logo, dsPIC, FlashFlex, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PIC32 logo, rfPIC, SST, SST Logo, SuperFlash and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MTP, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries. Analog-for-the-Digital Age, Application Maestro, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, SQI, Serial Quad I/O, Total Endurance, TSHARC, UniWinDriver, WiperLock, ZENA and Z-Scale are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. GestIC and ULPP are registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries. All other trademarks mentioned herein are property of their respective companies. © 2010-2013, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper. ISBN: 9781620771280 QUALITY MANAGEMENT SYSTEM CERTIFIED BY DNV == ISO/TS 16949 == 2010-2013 Microchip Technology Inc. Microchip received ISO/TS-16949:2009 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Company’s quality system processes and procedures are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified. DS00001365D-page 11 Worldwide Sales and Service AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: http://www.microchip.com/ support Web Address: www.microchip.com Asia Pacific Office Suites 3707-14, 37th Floor Tower 6, The Gateway Harbour City, Kowloon Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 India - Bangalore Tel: 91-80-3090-4444 Fax: 91-80-3090-4123 India - New Delhi Tel: 91-11-4160-8631 Fax: 91-11-4160-8632 Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 India - Pune Tel: 91-20-2566-1512 Fax: 91-20-2566-1513 France - Paris Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Japan - Osaka Tel: 81-6-6152-7160 Fax: 81-6-6152-9310 Germany - Munich Tel: 49-89-627-144-0 Fax: 49-89-627-144-44 Atlanta Duluth, GA Tel: 678-957-9614 Fax: 678-957-1455 Boston Westborough, MA Tel: 774-760-0087 Fax: 774-760-0088 Chicago Itasca, IL Tel: 630-285-0071 Fax: 630-285-0075 Cleveland Independence, OH Tel: 216-447-0464 Fax: 216-447-0643 Dallas Addison, TX Tel: 972-818-7423 Fax: 972-818-2924 Detroit Farmington Hills, MI Tel: 248-538-2250 Fax: 248-538-2260 Indianapolis Noblesville, IN Tel: 317-773-8323 Fax: 317-773-5453 Los Angeles Mission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608 Santa Clara Santa Clara, CA Tel: 408-961-6444 Fax: 408-961-6445 Toronto Mississauga, Ontario, Canada Tel: 905-673-0699 Fax: 905-673-6509 Australia - Sydney Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 China - Beijing Tel: 86-10-8569-7000 Fax: 86-10-8528-2104 China - Chengdu Tel: 86-28-8665-5511 Fax: 86-28-8665-7889 China - Chongqing Tel: 86-23-8980-9588 Fax: 86-23-8980-9500 Netherlands - Drunen Tel: 31-416-690399 Fax: 31-416-690340 Korea - Daegu Tel: 82-53-744-4301 Fax: 82-53-744-4302 Spain - Madrid Tel: 34-91-708-08-90 Fax: 34-91-708-08-91 China - Hangzhou Tel: 86-571-2819-3187 Fax: 86-571-2819-3189 Korea - Seoul Tel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934 China - Hong Kong SAR Tel: 852-2943-5100 Fax: 852-2401-3431 Malaysia - Kuala Lumpur Tel: 60-3-6201-9857 Fax: 60-3-6201-9859 China - Nanjing Tel: 86-25-8473-2460 Fax: 86-25-8473-2470 Malaysia - Penang Tel: 60-4-227-8870 Fax: 60-4-227-4068 China - Qingdao Tel: 86-532-8502-7355 Fax: 86-532-8502-7205 Philippines - Manila Tel: 63-2-634-9065 Fax: 63-2-634-9069 China - Shanghai Tel: 86-21-5407-5533 Fax: 86-21-5407-5066 Singapore Tel: 65-6334-8870 Fax: 65-6334-8850 China - Shenyang Tel: 86-24-2334-2829 Fax: 86-24-2334-2393 Taiwan - Hsin Chu Tel: 886-3-5778-366 Fax: 886-3-5770-955 China - Shenzhen Tel: 86-755-8864-2200 Fax: 86-755-8203-1760 Taiwan - Kaohsiung Tel: 886-7-213-7828 Fax: 886-7-330-9305 China - Wuhan Tel: 86-27-5980-5300 Fax: 86-27-5980-5118 Taiwan - Taipei Tel: 886-2-2508-8600 Fax: 886-2-2508-0102 China - Xian Tel: 86-29-8833-7252 Fax: 86-29-8833-7256 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350 UK - Wokingham Tel: 44-118-921-5869 Fax: 44-118-921-5820 China - Xiamen Tel: 86-592-2388138 Fax: 86-592-2388130 China - Zhuhai Tel: 86-756-3210040 Fax: 86-756-3210049 DS00001365D-page 12 Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781 Japan - Tokyo Tel: 81-3-6880- 3770 Fax: 81-3-6880-3771 11/29/12 2010-2013 Microchip Technology Inc.