Background
In order to ensure the stable and reliable operation of the circuit in the singlechip system, the reset circuit is an indispensable part, and no matter which type of singlechip is used by a user, the design of the singlechip reset circuit is always involved. The reliability of the whole system work is directly influenced by the design of the reset circuit of the single chip microcomputer. Many users have the phenomena of dead halt, program flying and the like on the site after designing a singlechip system and successfully debugging in a laboratory, which is mainly caused by unreliable design of a reset circuit of the singlechip. The single chip microcomputer is reset when being started, so that the MCU and all parts of the system are in a determined initial state, and the single chip microcomputer starts to work from the initial state. The reset signal of 89 series single-chip computer is inputted into Schmitt trigger in the chip from RST pin. When the system is in normal operation and the oscillator is stable, if there is a high on the RST pin for more than 2 machine cycles (24 oscillation cycles), the MCU can respond and reset the system.
In the prior art, the means for starting the reset circuit mainly include the following: firstly, when the circuit is electrified, the reset operation is immediately carried out; secondly, manual operation can be performed when necessary; and thirdly, the operation is automatically carried out according to the requirements of a program or a circuit. For some conventional resets, an RC manual reset is generally used or a dedicated reset chip is used for resetting. When the traditional reset circuit is powered on during starting, the reset circuit outputs a low level for a certain time to enable the reset chip to be in a reset state, so that reset is completed, the reset action is completed at the moment that an RC reset module or a reset chip is changed from low to high, and then the system starts a normal working mode. The method generally has no great problem for reliable MCU, but many MCU always have the situation that the probability can not be normally started, and the normal start can be restarted again only by re-electrifying the system or manually pressing a reset key. A conventional reset circuit is shown in fig. 1. As can be seen from fig. 1, the existing reset circuits based on the RC reset module are all unidirectional, and it is not known whether the reset IC is really reset, and if the reset IC is an MCU, it is also not known whether the MCU is reset and started normally.
Disclosure of Invention
The invention provides a closed-loop control reset circuit based on an RC reset module, which aims to solve the problem of single direction of the traditional reset mode and overcome the problem of incapability of starting a machine due to failure of normal reset.
This closed-loop control reset circuit based on RC resets module includes RC resets module U1, NOT gate circuit U2, NOT gate circuit U3, singlechip U4, resistance R3, electric capacity C2, its characterized in that: the NOT gate circuit U2, the resistor R3 and the capacitor C2 form an oscillator; the default input pin GPIO2 of the singlechip U4 is connected with the input of an oscillator, the output of the oscillator is connected with the input end of a NOT gate circuit U3, and the output end of the NOT gate circuit U3 is connected with the RESET pin RESET of the singlechip U4. The output end of the oscillator is the output end of a NOT gate circuit U2, the input end of the oscillator is the input end of a NOT gate circuit U2, the input end of the NOT gate circuit U2 is connected with the output end of a NAND gate circuit U2 through a resistor R3, and the input end of the NOT gate circuit U2 is grounded through a capacitor C2. The power supply pin of the RC reset module U1 is grounded through a resistor R1 and a capacitor C1, a reset button is connected in parallel with two ends of the capacitor C1, and the connection point of the resistor R1 and the capacitor C1 is a reset output terminal nRESET. The reset output terminal nRESET of the RC reset module U1 is connected with the cathode of a diode D2 through a current limiting resistor R2, and the anode of a diode D2 is connected with the input terminal of the oscillator. And a default input pin of the singlechip U4 is connected with the ground through a pull-down resistor R4 and is connected with the input end of the oscillator through a diode D1 and a current-limiting resistor R5. And the reset pin of the singlechip U4 is effective in low level. The default state of the default input pin of the singlechip U4 is low level, and the default input pin outputs high level after the singlechip U4 normally operates. The diodes are all Schottky diodes. The discharge time constant of the oscillator is larger than the time required by normal reset of the single chip microcomputer. After the reset button is pressed, the reset output terminal nRESET of the RC reset module U1 outputs low level. The closed-loop control reset circuit can greatly improve the reset reliability of the system.
Detailed Description
As shown in fig. 2, the closed-loop control reset circuit of the present invention includes an RC reset module U1, a single chip microcomputer U4, a not gate circuit U2, a not gate circuit U3, a diode D1, a diode D2, a resistor R1, a resistor R2, a resistor R3, a resistor R4, a resistor R5, a capacitor C1, and a capacitor C2.
The VCC input requirement of the power supply pin of the RC reset module U1 is 3.3V, the power supply pin is grounded through a resistor R1 and a capacitor C1, and the reset button is connected in parallel at two ends of the capacitor C1. When the reset button is pressed, the stored electric energy at the two ends of the capacitor C1 is quickly released, and then after the reset button is released, the power supply VCC charges the capacitor C1 through the resistor R1, and the reset output nrest of the RC reset module U1 becomes high after the low level of about 200ms, so that the process that the reset output nrest of the RC reset module U1 goes from low level to high level is completed. In the normal state, the capacitor C1 ensures that the reset output nrest of the RC reset block U1 is maintained at a high level.
The RESET of the single chip Microcomputer (MCU) U4 is the RESET pin of the MCU, which is active low, i.e., when the pin level is low, it indicates RESET. The GPIO2 of the single chip Microcomputer (MCU) U4 is a default input pin (input pin), the pin is grounded through a pull-down resistor R4, so that the pin can be pulled down in level through the pull-down resistor R4, the GPIO2 is in low level in a default state, and when a program written in the U4 normally runs, the GPIO2 is pulled up, so that the peripheral circuit judges that the program is normally started, and the reset process is finished.
U2 is a non-gate, U2 forms an oscillator with resistor R3 and capacitor C2, and performs level inversion, and U3 is also a non-gate and performs level inversion. And under the coordination of the two NOT gate circuits, the closed-loop control of the reset circuit is realized. The diodes D1 and D2 are schottky diodes, which can achieve fast response and unidirectional conduction, and reduce loss by using their small voltage drop. The resistor R5 and the resistor R2 are current limiting resistors and play a role in limiting current, and the resistor R3 is matched with the capacitor C2 to finish the design of a discharge time constant.
The working process of the closed-loop control reset circuit is as follows: when the reset button is pressed, the RC reset module U1 immediately outputs low level, keeps the low level for about 200ms, and then becomes high level, during the low level keeping period of 200ms, if the system program is normally started, the GPIO2 is pulled high, the process of system reset is completed, if the U4 is not normally started, the GPIO2 will keep low level, then the PIN5 of the U2 inputs low level, the PIN 465 of the U2 outputs high level, the PIN6 of the U5857323 outputs low level, since the PIN6 of the U2 is high level and the PIN5 is low level, then the capacitor C2 is charged through the resistor R3, when the level on the capacitor C2 reaches the input high level threshold of the U2, the PIN5 of the U2 becomes high level, the PIN6 of the U2 outputs low level, then the 3 of the U3 outputs high level, if the U3 is not normally reset, the above process is cycled, so that the above process forms a square wave at the low PIN 3 of the PIN 3, the duty ratio and time of the square wave are determined by the values of the resistor R3 and the capacitor C2, that is, the charging and discharging time of the capacitor, the waveform of the PIN6 of the U3 is opposite to the waveform of the PIN6 of the U2, and is also a square wave of high and low levels, as long as the U4 is not RESET, the square wave will always occur and form high and low levels on the RESET PIN RESET of the U4, the width of the low level is larger than the time required by the normal RESET of the U4, until the U4 completes the normal RESET procedure and operates, once the U4 completes the RESET at the moment when the PIN 4 of the U4 becomes high level, the GPIO 4 immediately outputs high level, at this time, the PIN 4 of the U4 is high level, the PIN 4 is low level, the square wave oscillator composed of the U4, the R4 and the C4, the PIN 4 of the U4 keeps high level, the system completes the whole RESET procedure, and the whole procedure is formed by the input PIN 4 of the RC RESET module U4, the inverter composed of the U4, the PIN 4, the oscillator 4, therefore, the whole closed-loop process is completed, the absolute closed loop of the system is ensured, the MCU is successfully reset, and the program is operated.