How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51 This application note explains how the reset of the 80C51 microcontroller works when the RST pin is a pure input pin and when the RST input is bi-directional. It gives rules to determine the extra components required to operate the reset function properly. The reset process can be active on low or high level depending on the product. In this application note only the high level case is discussed. Microcontrollers Application Note Introduction The reset is used to start-up or to restart the 80C51 microcontroller activities. It forces the 80C51 in a known state by reinitializing all the internal registers needed to properly start the program execution. The reset must be kept active until all three of the following conditions are respected: • The power supply must be in the specified range. • The oscillator must reach a minimum oscillation level to ensure a good noise to signal ratio and a correct internal duty cycle generation. • The reset pulse width duration must be at least two machine cycles. If one of the conditions is not respected the microcontroller will not startup properly. Theory of Reset Operation To ensure a good startup, the reset pulse width has to be wide enough to cover the period of time where the electrical conditions are not met. Two parameters should be considered for a proper reset sequence to determine the reset pulse width (see Figure 1): • tosc: time needed by the oscillator to reach the Vih1 or Vil1 level. • tvddrise: rise time of the power-supply taken between 10 to 90% of VDD. When these two parameter conditions are met, the reset has to be maintained at least two machine cycles in order to synchronize the internal activity of the core. In normal mode, a machine cycle is 12-clock periods and in X2 mode is 6-clock periods. Rev. 4284A–8051–09/03 Figure 1. tosc and tvddrise are the Two Parameters to Evaluate, Depending on the Application treset tosc Vih1 VDD tvddrise XTAL1 Vih1 is the reference parameter taken to calculate and determine the time constant of the reset. Indeed, normally the input is considered to be low when its level reaches Vil1. But in reality the trigger is somewhere between Vih1 and Vil1. So, the worst case condition is considered at the Vih1 level. When the reset is released, the program execution starts and the ALE signal toggles as it is illustrated in Figure 2. and showing a proper startup condition: • VDD is within the voltage operating range, • The level of Xtal1 is greater than the Vih1 level specification, • The reset reached its active level (Vih1) and is maintained at least two machine cycles. Figure 2. Reset Conditions to Properly Startup a Microcontroller ALE V VDDDD Vrst Reset is released XTAL2 2 C51 Reset Guidelines 4284A–8051–09/03 C51 Reset Guidelines Why Does the Reset Does Not Properly Start the Microcontroller? The Oscillator is not Stabilized Figure 3 shows the case where the RST signal is applied while the oscillator is not stabilized and there is no clock to reset the internal registers of the CPU. Due to this bad reset, the first address fetched can be anywhere in the program space except address 0000h. Figure 3. If electrical Conditions are not Met, the Reset Signal is Applied but without the Clock ALE VDD The reset is applied while the clock is not stabilized XTAL2 Vrst Reset is Released before VDD is Stable Figure 4 shows the case where the reset is released before the VDD is stable. The microcontroller will never see the reset and can start anywhere in the program space and with a bad register initialization. Figure 4. The Reset is Released before the Clock and the VDD are Stable ALE VDD XTAL2 Vrst 3 4284A–8051–09/03 Reset Input Circuitry Description At least two kinds of reset input structure exist in C51 products. The first one is a pure input which allows an external device to reset the microcontroller. The second one is bidirectional. The microcontroller can be reset by an external device. The microcontroller can reset an external device when, for example the internal watchdog expires. Table 1 lists some C51 Atmel products which have uni-directional or bi-directional reset. Table 1. Examples of Products Using Uni-directional and Bi-directional Reset Product Main Features Uni/Bidir T83C51RB2 16 KB of ROM, Watchdog B T89C51RD2 64 KB of Flash, Watchdog B AT89C51CC01 10-bit ADC, CAN controller B AT89C51SND1 MP3 decoder, TWI, MMC, USB U uni-directional Reset Input Description The uni-directional reset input circuitry is shown in Figure 5. A pull-down resistor, Rrst, is connected between the RST input and the ground. An external capacitor, Crst, is connected between the RST input and the VDD. The value of Crst determines the reset time duration. The calculation of Crst is explained in the next chapter. Figure 5. Reset Structure for an uni-directional Circuitry Theory of Operation 4 When a reset is applied on the RST input, Crst is discharged and then charged through Rrst. The reset is active until the level applied on the RST pin is below Vih1. Crst determines the reset pulse width duration. C51 Reset Guidelines 4284A–8051–09/03 C51 Reset Guidelines Bi-directional Reset Input Description The bi-directional reset circuitry is shown in Figure 6. In addition to the uni-directional structure, the RST pin is able to drive an external reset for example when a watchdog expires. To do this, a pull-up resistor (Rrstwt) controlled by the rstcon signal drives a high level on the RST pin. An extra resistor (Rrstext) must be added between the RST input and Crst (Figure 6.). Figure 6. Reset Structure in a Bi-directional Mode 2 VDD 1 rstcon Crst Rrstwt Rrstext RST Internal reset Rrst External reset Reset circuitry vrst(t) Oscillator 2 X1 Q1 1 X2 ALE CPU clock Theory of Operation External Reset During a power-up or when an external reset is applied to the RST input, the Crst capacitor is charged through the two resistors Rrstext and Rrst. The reset is active until the level applied on the RST pin is below Vih1. The Rsrtext resistor is required when an internal reset is applied by the microcontroller and will be explained in the next session. Internal Reset In some cases, such as a watchdog reset, the microcontroller generates an internal reset by driving the rstcon signal and consequently by applying a high level on the RST pin. The pulse duration depends on the product and is typically equal to 96 clock periods (see the product datasheet). The Rrstext allows a reset pulse to occur on the RST pin. The reset time constant (several ms) is large in comparison to the reset pulse duration (96 clock periods). In that condition, Crst maintains its charge (VDD) for all the duration of the reset pulse even if Rrstwt is active (see Figure 7). VDD is applied across the Rrst and Rrstwt resistors and expression of Vrst is given below: Rrstext Vrst = VDD × ------------------------------------------Rrstext + Rstwt For a given Rrstwt resistance, Rrstext determines the active level of the reset pin. To take into account on the external and internal reset constraints, Rrstext must be chosen in the 1 kΩ and 10 kΩ range. 5 4284A–8051–09/03 Figure 7. Reset Circuitry When an Internal Reset is Applied VDD Rrstwt Internal reset Vrst Crst VDD Rrstext Rrst Vih1 0 0 Without Rrstext no external reset signal will be generated. Use Excel File to Determine Crst To determine Crst, the reset pulse width needs to be calculated using the following equation: treset = tvddrise + tosc • • tvddrise (typically 1 ms to 100 ms), is the rise time of the VDD (10% and 90% of the VDD). It depends on the power supply and the decoupling capacitors used. tosc (typically 1 ms to 50 ms), time taken by the oscillator at startup. It depends on the crystal characteristics and the capacitors connected to the crystal. Because the power supply has a finite transition time (several hundreds of microseconds to several milliseconds), Crst is not so easy to compute by hand. Excel tool is used to calculate Crst versus tvddrise and tosc parameters. A spreadsheet can be downloaded from the Atmel Web site to compute Crst. Four parameters have to be entered and Crst is directly computed by the spreadsheet while 1kΩ is chosen for Rrst. Here is how to do it: • VDD, the power supply voltage, is entered in the cell F3 • tvddrise, the rise time of the power-supply, is entered in the cell F4 • tosc, the oscillator startup time, is entered in cell F8 • Rrstmin, the minimum pull-down resistor, is entered in the cell F13 After these steps, the cell E31 has to be clicked to compute the Crst and the minimum reset pulse width. 6 C51 Reset Guidelines 4284A–8051–09/03 C51 Reset Guidelines Table 2. Excel Spreadsheet Use to Calculate Crst Power Supply Characteristics VDD = 5 V tvddrs = 1 ms tosct = 10 ms Rrstmin = 100 kΩ trstmin = 22, 726 ms Minimum reset pulse width Trst = 65, 545 ms Value of reset capacitor C C= 0.649 µF Power Supply Voltage Power Supply Rise Time (10% to 90%) Oscillator Oscillator Startup Time time, measured at VIH1 Electrical Characteristics of the Reset Input Minimum pull-down resistance Minimum Pulse Width Calculation of the reset pulse width Evaluation of Reset Capacitor: C Table 3 gives the Crst value computed from the Excel file for different values of tvddrise and tosc parameters. Table 3. Minimum Reset Capacitor Value for a 50kΩ Pull-down Resistor (Rrstmin) tvddrise tosc 1 ms 10 ms 100 ms 5 ms 820 nF 1.2 µF 12 µF 20 ms 2.7 µF 3.9 µF 12 µF Table 4. Minimum Reset Capacitor Value for a 100KΩ Pull-down Resistor tvddrise tosc 1 ms 10 ms 100 ms 5 ms 390 nF 0.56 µF 5.6 µF 20 ms 1.2 µF 2 µF 5.6 µF 7 4284A–8051–09/03 Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 Literature Requests www.atmel.com/literature Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard warranty which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products are not authorized for use as critical components in life support devices or systems. © Atmel Corporation 2003. All rights reserved. Atmel ® and combinations thereof are the registered trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be the trademarks of others. Printed on recycled paper. 4284A–8051–09/03