Watchdog (monitoring chip)

By the microcontroller configured microcomputer system , since the work microcontroller often subject to interference from external electromagnetic fields, resulting in various registers and memory of data corruption, will cause the program pointer errors, not in the program area, program instructions, etc. to remove the error, are likely to fall into an infinite loop, the normal operation of the program is interrupted, the system controlled by the MCU can not continue to work properly, causing the entire system to a standstill, unpredictable consequences.
Watchdog, Watchdog called, is essentially a timer circuit, generally have an input and an output, wherein the input is called the dogs, the output is typically connected to the reset terminal of another part, usually connected to the microcontroller. The watchdog function is regular viewing situation inside the chip, once the error has occurred on the issue of restarting signal to the chip. Watchdog command has the highest priority interrupt program.

definition

edit
Watchdog, called watchdog timer, a timer circuit, generally have an input, called the dogs (kicking the dog / service the dog ), a RST output terminal of the MCU, the MCU normal operation time, at intervals outputs a signal to the time the dogs end to the WDT is cleared, if the predetermined time is not more than feed the dog (usually in the program running), WDT timer exceeds, will give a reset signal to the MCU, the MCU to reset. MCU prevent the crash. Watchdog role is to prevent the occurrence of an infinite loop program, or the program running.  [1] 

Fundamental

edit
Watchdog is a means for monitoring the health of the system to achieve the monitoring of the health of the system by way of a combination of hardware and software. Stable operation of the software will be performed after the dogs completed specific instruction is executed, if the watchdog does not receive a signal from the software of the dogs in a certain period, then that system failure, or to interrupt routine will force a system reset. After the system may be selected to enable the watchdog timing depending on the operating mode is enabled if the watchdog counter starts counting, watchdog timeout if the dogs did not within a set period of time it occurs. Watchdog consists essentially registers, counters and dog modules: basic settings, the time counter counts the dog, dog module determines watchdog interrupt or reset mode after a timeout of the watchdog emitted by the register.  [2] 

application

edit
Application of the watchdog circuit, so that the microcontroller can be realized in the absence of continuous operation state, its working principle is: a watchdog chip microcontroller and I / O pins connected to the I / O pin that controls the timing by the program the watchdog to this pin into a high level (or low level ), the program statements dispersed placed MCU other control statements intermediate, once the microcontroller due to interference, and into a program running a block enters an infinite loop, the program will write the watchdog pin can not be executed, this time, the watchdog circuit will not be obtained due to the signal sent by MCU, and it will reset pin of the microcontroller a feeding pin on reset signal , causes the microcontroller reset occurs. That program from the program memory begins execution start position, this will automatically reset the device to achieve.  [3] 

classification

edit

Hardware Watchdog

Is the use of a hardware watchdog timer to monitor the operation of the main program, that is in the process of running the main program, we want to reset the timer before the time expires. If an infinite loop, or PC appear pointer can not come back, so after regular time to make MCU reset. WDT conventional chips such as MAX813,5045, IMP 813 and the like.

Software Watchdog

In some cases, the methods are used to set the watchdog pure software, as in the SCM system, using the idle timer / counter can be designed a software watchdog. Specific steps are as follows:
First, the arrangement timer / counter in the initialization process to control the initial value register (the TMOD) and the timer time, and interrupts are enabled.
Then, according to the time of the timer, the main program in a certain time interval insertion instructions the reset timer (DOG), the time interval between two instructions can be calculated from the dogs system clock and the instruction cycle, and this time period should be less than the timer has expired.
Finally, the timer interrupt service routine, set an unconditional branch instruction, the program counter PC is transferred to the entrance initialization procedure.
In the non-single-chip systems, such as PowerPC system, may be used to set up multi-threaded manner dongle, the main steps are as follows:
First, create a watchdog thread that maintain a global variable array that corresponds to each worker thread counter. A watchdog thread into a loop, once in a while loop once, and each value of a global variable arrays are added after 1 determines the upper limit exceeds a predefined, if found a thread corresponding variable exceeds the maximum value, resets the watchdog thread the thread.
Then, each worker thread will periodically corresponding global variable is set to 0 (DOG).
Software Watchdog advantage is that no additional hardware support, but there are serious errors system (for example: interrupt service error), it may lead to failure of the software watchdog.  [4]

Guess you like

Origin www.cnblogs.com/mhq-martin/p/11575983.html