The watchdog circuit of the abnormal forced resetting of a kind of microcontroller
Technical field
The utility model relates to microcontroller in embedded system (MCU) software and runs reset when flying and the forced resetting circuit under hardware deadlock situation.
Background technology
Microcontroller (MCU) is because being subject to external interference or other cause influence in embedded systems, often there will be the phenomenon of deadlock or program fleet, causes product cisco unity malfunction.Industry uses watchdog technique to solve this problem, and system reset deadlock or race flown by house dog also makes it normally work.House dog is divided into microcontroller house dog and outer watchdog.Inner house dog utilizes MCU internal resource to realize, and comprises internal proprietary house dog or uses timer internal to realize watchdog function.Open after watchdog function, MCU will by software regular to timer again initialize or clearing (feeding dog), once MCU is abnormal, timer will overflow, and internal hardware meeting carry out reset operation to MCU automatically.Outer watchdog refers to the situation increasing watchdog chip or circuit realiration watchdog function in MCU outside.Substantially all use external dedicated watchdog chip at present, pole individual product can use the watchdog circuit of outside designed, designed.Because watchdog chip can meet reset demand during conventional MCU exception.Outer watchdog is opened when powering on, and MCU needs to realize feeding dog function, once MCU is abnormal by the level change of IO pin, feed dog control pin change time-out, outer watchdog will produce reset signal, and reset signal is added to the external reset pin of MCU, makes system reset.
External special watchdog chip or circuit are actually a special timer, when timing then, send overflow pulse, this Puled input on the external reset pin of single-chip microcomputer, thus realizes system reset.Software in time performs dog feeding operation (removing outer watchdog by controlling pin change) in main program cycle, and when guarantee system is normally run, house dog is not overflowed; And when system cloud gray model is abnormal, house dog time-out sends overflow pulse, makes monolithic processor resetting by the RESET pin of single-chip microcomputer.This mode compares internal hardware house dog and software watchdog is more reliable, does not exist and causes because of electrification reset failure the possibility that inner house dog and software watchdog lost efficacy, and shortcoming needs outer distribution chip or circuit.Integrated watchdog circuit conventional is at present a lot, as DS1232, MAX705 ~ 708, MAX791 etc.Fig. 1 is the circuit diagram of DS1232 chip and AT89C52 chip, and single-chip microcomputer is by the feeding-dog signal of P3.3 foot control DS1232, and this feeding-dog signal provided in the opportune moment of master routine, and ensure that DS1232 chip does not overflow, RST pin then remains low level; When single chip microcomputer halt, P3.3 pin no longer provides feeds dog pulse, then after when DS1232 is timed to, RST pin exports high level pulse by monolithic processor resetting.
, there is following defect in existing watchdog circuit:
1, the inner house dog of MCU when this function is not opened by software by inoperative.Inner house dog will be lost efficacy when MCU deadlock.
2, outer watchdog is fed dog pin to be designed to Low level effective or high level effective, and when MCU crashes, the state of hello dog pin is indefinite.If consistent with the significant level that outer watchdog feeds dog pin, outer watchdog will be caused to lose efficacy.
3, to feed dog condition simple for outer watchdog, is generally low and high level and changes, system be interfered or MCU software anomaly time easy mistake generation hello dog condition, make outer watchdog cisco unity malfunction.
4, outer watchdog reset signal is directly connected on the resetting pin of MCU, and when MCU deadlock, MCU internal protection gets up, can not normal reset MCU by this pin.
5, outer watchdog be with MCU resetting pin with the use of, reset level is all shorter for effective time, generally at Millisecond, is not suitable for carrying out power-off restoration.All contain larger electric capacity in system, the electric quantity consumption of storage can not effectively fall by the power failure of Millisecond, therefore can not realize power-off restoration.
Utility model content
The purpose of this utility model is the watchdog circuit providing the abnormal forced resetting of a kind of reliable microcontroller, makes MCU no matter fly, with under deadlock situation, all can effectively reset to system in software race, thus the reliability service of the system of guarantee, product.
The watchdog circuit of the abnormal forced resetting of microcontroller described in the utility model, comprises a CD4017 counter module, the 2nd CD4017 counter module, 555 pierce circuit modules and level shifting circuit module;
Described level shifting circuit, voltage transitions for the feeding-dog signal inputted by MCU becomes the voltage with a CD4017 counters match, its input end connects the output pin of MCU feeding-dog signal, its output terminal connects the Puled input pin (CLK pin) of a CD4017 counter module, and the feeding-dog signal after level shifting circuit conversion is input to a CD4017 counter module;
Described 555 pierce circuit modules, for the pulse signal of generating period, and are transported to the resetting pin (RST pin) of a CD4017 counter module and the Puled input pin (CLK pin) of the 2nd CD4017 counter module by the pulse signal of generation;
A described CD4017 counter module, its Puled input pin (CLK pin) connects the output terminal of level switch module, resetting pin (RST pin) is then connected with the output terminal of 555 pierce circuit modules, and its data output pin Q8 pin is then connected to the resetting pin (RST pin) of the 2nd CD4017 counter module; It feeds dog pulse by ten, changes into a pulse signal and is supplied to the second counter as reset signal;
2nd CD4017 counter module, its frequency input pin (CLK pin) connects the output terminal of 555 pierce circuit modules, its resetting pin (RST pin) connects the data output pin Q8 of a CD4017 technology device module, its data output pin Q9 is then connected to the power circuit that control MCU works, by power circuit control to the power supply of MCU and power failure; It receives the pulse signal of 555 vibrator circuit modules and the reset signal of a CD4017 counter module, the power supply of control MCU and power failure.
555 pierce circuit modules, the pulse signal in any dutycycle and cycle can be produced, this pulse signal provides Puled input for the 2nd CD4017 counter module, one CD4017 counter module resets by the high level of each pulse simultaneously, and the RST pin high level of a CD4017 counter module is effective.
When the resetting pin (RST) of the 2nd CD4017 counter module remains low level, when namely not performing effective hello dog, continuous 9 pulses that 555 pierce circuit modules produce can make the data output pin Q9 of the 2nd CD4017 counter module become high level from low level, now MCU power circuit can turn off the power supply of MCU, and house dog performs power down function.After time delay to the one-period of 555 pierce circuit modules, the 10th pulse produced can make the data output pin Q9 of the 2nd CD4017 counter module become low level from high level, now MCU power circuit will re-power MCU and other element, and now house dog executes power-off restoration function.Feeding-dog signal input pin (WatchDog) to be continued through within the time of 555 pierce circuit module output low levels when MCU normally runs and input 10 pulses to watchdog circuit, the data output pin Q8 of a CD4017 counter module is made to produce 1 high level pulse, the resetting pin (RST) that this high level pulse is applied to the 2nd CD4017 counter module makes the 2nd CD4017 counter module reset (again counting), is once effectively feed dog like this.As long as performed 1 time effectively feed dog in front 8 pulses of 555 pierce circuit modules, the 2nd CD4017 counter module just can count again, which decreases the complexity of MCU program.
Watchdog circuit described in the utility model, overcome common house dog and feed dog condition simply, easily fed the shortcoming of dog, simultaneously because the recurrence interval can from Row sum-equal matrix by mistake, can realize the power-off forced resetting function of long period, be very practical and effective MCU monitoring circuit.Application testing in commercial production, proves effective settlement procedure race to fly and deadlock situation.
Watchdog circuit described in the utility model, hello dog level demand continuous 10 pulse signals within the set time are just effective.Improve and feed the complicacy of dog, the level change of feeding dog pin that abnormal and interference is caused can not be consistent with effective feeding-dog signal, thus avoid producing and miss hello dog phenomenon, and house dog was lost efficacy.
Meanwhile, its house dog is performed when resetting and is not resetted by the reset pin of MCU, but adopts direct power-off, time delay, the forced resetting mode that re-powers.To be so no matter that software race flies or deadlock situation, effective reset can be realized.
Accompanying drawing explanation
Fig. 1 is a kind of schematic diagram of existing watchdog circuit.
Fig. 2 is the schematic diagram of watchdog circuit described in the utility model.
Fig. 3 is LM2575-3.3 voltage regulator module circuit diagram.
Embodiment
As Fig. 2, a kind of watchdog circuit, comprises a CD4017 counter module, the 2nd CD4017 counter module, 555 pierce circuit modules and level shifting circuit module; Described level shifting circuit, voltage transitions for the feeding-dog signal inputted by MCU becomes the voltage matched with a CD4017 counter module, its input end connects the output pin of MCU feeding-dog signal, its output terminal connects the Puled input pin (CLK pin) of a CD4017 counter module, and the feeding-dog signal after level shifting circuit conversion is input to a CD4017 counter module; Described 555 pierce circuit modules, for production burst signal, and are transported to the resetting pin (RST pin) of a CD4017 counter module and the Puled input pin (CLK pin) of the 2nd CD4017 counter module by the pulse signal of generation; A described CD4017 counter module, its Puled input pin (CLK pin) connects level switch module and obtains output terminal, resetting pin (RST pin) is then connected with the output terminal of 555 pierce circuit modules, and its data output pin Q8 pin is then connected to the resetting pin (RST pin) of the 2nd CD4017 counter module; 2nd CD4017 counter module, its Puled input pin (CLK pin) connects the output terminal of 555 pierce circuit modules, its resetting pin (RST pin) connects the data output pin Q8 of a CD4017 technology device module, its data output pin Q9 is then connected to the power circuit that control MCU works, and controls the power supply to MCU by power circuit.
Described 555 pierce circuit modules are 555 basic pierce circuits, it comprises ICM7555 chip, electric capacity C602 is connected between the 5th pin (Cvolt) and GND end of ICM7555 chip, electric capacity C601 is connected between THR end is held with GND, to hold with VCC at R end and be connected, TRIG end is held with THR and is connected, and is connected R602 at DIS end with between GND, between DIS end is held with VCC, be connected R601.The pulse in any dutycycle and cycle can be produced by the parameter adjusting R601, R602, C601.
Described level shifting circuit module is switch triode circuit, during Watch_Dog input low level, exports as high level+12V, matches with a CD4017 counter power supply; During Watch_Dog input high level, export as low level.
The data output pin Q9 of the 2nd CD4017 counter module can connect the 5th pin of LM2575-3.3 voltage stabilizer, by the power supply of LM2575-3.3 voltage regulator module control MCU, as Fig. 3.When the data output pin Q9 output level of the 2nd CD4017 counter module is high level, perform turn-off function, turned off by+3.3V voltage, the MCU now powered by+3.3V and other element will have a power failure, and now house dog performs power failure function.
When after time delay to the one-period of 555 pierce circuit modules, the 10th pulse produced can make the data output pin Q9 of the 2nd CD4017 counter module become low level from high level, now the 5th pin of LM2575-3.3 is low level, its turn-off function lost efficacy, continuation is powered by+3.3V voltage, powered operation again incited somebody to action by the MCU now powered by+3.3V and other element, and now house dog executes power-off restoration function.