Shenzhen ZTRON Microelectronics Co., Ltd
Telephone
0755-8299 4126

MCU

MCU Watchdog Technology


Realization Method of Watchdog Technology in Single Chip Microcomputer System


1. Overview of single-chip microcomputer and watchdog technology


Single-chip microcomputer systems are more and more widely used in military, industrial, and civilian products. It completes many functions realized by hardware in the past by software, which is small in size, rich in functions and highly intelligent. Affected by the system structure, manufacturing process, selection and installation of components, these are the interference factors of the single-chip microcomputer system, which bring many problems to the reliability of the system. These disturbances will cause the single-chip program to fly to a temporarily formed infinite loop or the PC pointer to fall outside the address of the program memory chip. In this case, redundant instructions and software traps cannot be resolved, and the system will be completely paralyzed. In this case, only reset. Therefore, the watchdog technology is a timer circuit that can issue a reset signal. Setting the watchdog is an important way to prevent the single-chip from crashing and improve the anti-interference performance of the single-chip system. The watchdog technology can be divided into single-time watchdog, dual-time watchdog, and timing reset watchdog. This article mainly introduces the implementation method and principle of watchdog technology.


The most widely used watchdog circuit is actually a special timer circuit. The watchdog counts at a fixed rate, and when the preset time is over, an overflow pulse is sent to reset the microcontroller. If the timer is forced to be cleared every time before the timer overflows, no overflow pulse will be issued. The clearing pulse is sent by the CPU, and the watchdog will not overflow in the microcontroller. Once the program enters an infinite loop without feeding the dog statement. This article calls this kind of watchdog a typical watchdog. Typical watchdogs have been integrated, such as MAX706, MAX791, X5045, etc. There are also many single-chip computers that integrate this kind of watchdog, such as P89C669 and P89V51RD2 of NXP. And other single-chip microcomputers, the specific circuit can refer to the technical information of these chips. The following will take the X5045 as an example to introduce the implementation of single-time limit and double-time limit watchdog.


2. Single-time watchdog


The method of using only a single watchdog timer to control the reset terminal of the single-chip microcomputer is called a single-time limit watchdog, which is relatively simple in circuit implementation, and can effectively control the normal operation of the single-chip microcomputer system under normal circumstances. Figure 1 shows the hardware circuit diagram of the single-time limit watchdog realized by the X5045 watchdog chip. In the figure, P1.0 of the single-chip microcomputer provides chip selection signal for X5045, P1.1 receives serial data of X5045, P1.2 provides serial clock, P1.3 sends serial data to X5045, RST pin of X5045 and single-chip microcomputer The RST pin is connected to reset the microcontroller. In the MCU control program, a "feed the dog" instruction is placed at a certain time interval, which is less than the preset timing time of X5045, so as to ensure that X5045 will not overflow when the program is running normally; and once the program is abnormal, X5045 will time out and overflow , and send a reset signal through the RST pin to reset the MCU and start running the program again.


3. Dual time limit watchdog


There is a wrong view: add a watchdog, the microcontroller will not crash. In fact, the watchdog sometimes fails completely. When the program enters an infinite loop, and the infinite loop contains the dog feeding statement, the watchdog will never overflow, the single-chip microcomputer will never get a reset signal, and the program will never escape from this infinite loop. In view of this drawback, it is necessary to design a dual-time limit watchdog system. Figure 2 shows the dual-time limit watchdog hardware circuit. One X5045 watchdog chip is added on the basis of the single-time watchdog, and the two watchdogs are connected to the RST pin of the microcontroller in the form of an OR gate. As long as there is one X5045 timeout overflow, the microcontroller is reset.


The dual-time limit watchdog has two timers: one is a short timer and the other is a long timer. The timing of the short timer is T1, and the timing of the long timer is T2, 0<T1≤T2; the feeding of the long and short timers is independent. The short timer works like a typical watchdog, which ensures that the watchdog has a fast response speed under normal circumstances; the timing T2 of the long timer is greater than the time for the CPU to execute a main loop program, and each main loop only feeds the dog once , used to prevent the watchdog failure.


In this way, when the program enters an infinite loop, if the infinite loop contains a short timer feeding dog statement but does not contain a long timer feeding dog statement. Then the long timer will eventually overflow and reset the microcontroller. Cleverly arrange the position of the long timer feeding dog statement, which can ensure that the probability of crash is extremely low.


Almost all watchdogs currently rely on the CPU (depending on the CPU to feed the dog). This can be compared to: whether an insurance device can play an insurance role also depends on the behavior of the object it protects. Obviously, the watchdog that relies on the CPU cannot guarantee that the single-chip microcomputer will not crash 100%.


4. Timing reset watchdog


The main body of the regular reset watchdog is also a timer, and when the predetermined time is reached, an overflow pulse is sent out, and this overflow pulse causes the single-chip microcomputer to reset forcibly. Timed reset watchdog does not need CPU to feed the dog.


In short, the regular reset watchdog is to reset the MCU forcibly at regular intervals. In this way, even if the device is dead, its maximum dead time will not be greater than the timing time of the timer. Obviously, as long as the hardware is intact, this kind of watchdog can guarantee 100% that the microcontroller will not crash for a long time.


It is more commonly used to use the 555 timer as a watchdog to connect with the RST of the single-chip microcomputer, as shown in Figure 3, when the power is turned on, C4 is charged through the resistors R1 and R2, and the pin 3 outputs a low level, and the power-on reset of the single-chip microcomputer starts normal work. By adjusting the resistance value of resistor R2, the time T of the output level of the 555 timer can be adjusted to meet the time requirement of the reset of the single-chip microcomputer. The time output by the 555 should be able to meet the working time of the main cycle of the single-chip microcomputer, so that the single-chip microcomputer can work completely .


epilogue


This article briefly introduces several typical watchdog working methods and principles. In the specific design process, actual needs should be considered, and the most suitable watchdog design scheme should be adopted to obtain better anti-interference effect. On the contrary, an unreasonable design of the watchdog system will not only fail to provide system reliability, but will cause the system not to work normally. Therefore, when designing a single-chip microcomputer system, watchdog design is an important consideration.


The above are the details of the implementation method of the watchdog technology in the single-chip microcomputer system introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. for you. If you have software and hardware function development needs for smart electronic products, you can rest assured to entrust them to us. We have rich experience in customized development of electronic products, and can evaluate the development cycle and IC price as soon as possible, and can also calculate PCBA quotations. We are a number of chip agents at home and abroad: Songhan, Yingguang, Jieli, Ankai, Quanzhi, realtek, with MCU, voice IC, Bluetooth IC and module, wifi module. We have hardware design and software development capabilities. Covering circuit design, PCB design, single-chip microcomputer development, software custom development, APP custom development, WeChat official account development, voice recognition technology, Bluetooth wifi development, etc. It can also undertake the research and development of smart electronic products, the design of household appliances, the development of beauty equipment, the development of Internet of Things applications, the design of smart home solutions, the development of TWS earphones, the development of Bluetooth earphone speakers, the development of children's toys, and the development of electronic education products.


  • TOP