Introduction to dog

Source: Internet
Author: User

We can see that the design of the watchdog is very similar to the principle and function of the most external timer of our team. Recently, we have seen many embedded underlying principles that coincide with the team's current ideas. As a result, our team's design philosophy is correct! We should continue unswervingly!

In another case, teacher Yao suggested that I change the Redirect method of exception handling to redirection after decision-making. At that time, I didn't think much about his ideas. Now it seems that online decision-making is impossible in the case of high real-time requirements, and it is necessary to jump unconditionally!

 

In a microcomputer system composed of Single-chip Microcomputer,
Because the single-chip microcomputer is often affected by external electromagnetic fields, the program runs and falls into an endless loop. the normal operation of the program is interrupted, and the system controlled by the single-chip microcomputer cannot continue to work, will cause the entire system
The system is stuck and has unpredictable consequences. Therefore, in consideration of the real-time monitoring of the single chip microcomputer running status, a chip is generated to monitor the running status of the single chip microcomputer,Commonly known as "Watchdog"(Watchdog)

The application of the Watchdog Circuit enables the single-chip microcomputer to work continuously in the unmanned State. Its working principle is: the watchdog chip and the single-chip microcomputer
An I/O pin is connected, and the I/O pin is controlled by a program to regularly send high (or low) to this pin of the watchdog ), this Program Statement is distributed in the middle of other MCU control statements.
Once the single-chip microcomputer causes the program to fly due to interference, it falls into a certain program segment.
When it enters the endless loop state, the program that writes the watchdog pin cannot be executed. At this time, the watchdog circuit will not receive the signal sent by the microcontroller, sends
The reset signal enables the microcontroller to reset, that is, the program starts from the initial position of the program memory, so that the microcontroller can be automatically reset.
Watchdog timer is a timer circuit,
There is usually an input called kicking the dog or service
Dog), an output to the MCU's RST end. When the MCU works normally, a signal is output at every end to the dog Feed End to the WDT
Resetting: if the number of times exceeds the specified time, the system will not feed the dog (usually when the program is running). If the WDT time exceeds the threshold, a reset signal will be returned to the MCU, which is used to reset the MCU to prevent the MCU from crashing.
The role of the watchdog is to prevent an endless loop of programs, or to run programs.
Working principle: After the system runs, the watchdog counter is started, and the watchdog starts to automatically count. If it does not clear the watchdog at a certain time, then the watchdog counter will overflow and cause the watchdog to interrupt, resulting in system reset. Therefore, when using a chip with a watchdog, you must clear the watchdog.
The Hardware Watchdog uses a timer to monitor the running of the main program. That is to say, during the running of the main program
If an infinite loop occurs when the timer time is reset to the previous time, or the PC pointer cannot return. After the scheduled time is reached, the microcontroller will be reset. Common WDT chips such as MAX813
, 5045, IMP 813, etc., price 4 ~ 10 yuan.
The principle of the Software Watchdog Technology is similar to this, but it is implemented using the software method. We are still talking about the 51 series.
There are two timers in the 51 microcontroller. We can use these two timers to monitor the operation of the main program. We can set a certain scheduled time for T0. When a scheduled interruption occurs
Assign values, and this variable has an initial value at the beginning of the main program running. Here we want to set a scheduled value smaller than the running time of the main program, in this way, the variable value is determined at the end of the main program, as shown in figure
If the value changes as expected, the T0 interruption is normal. If the value does not change, the program is reset. For T1 we use to monitor the operation of the main program, we set a certain scheduled time for T1, in the main program
Reset it. If it cannot be reset within a certain period of time, T1
Will reset the microcontroller. Here, the scheduled time of T1 is greater than the running time of the main program, leaving some margin for the main program. The T1 interruption is normal or not, and we will interrupt the child from T0.
Program to monitor. In this way, it becomes a loop. T0 monitors T1 and T1, and the main program monitors T0 again to ensure the stable operation of the system.

Watch Dog Usage Note: Most 51
All the series of single-chip microcomputer have a watchdog. When the watchdog is not regularly cleared to zero, it will cause reset. This prevents programs from flying. The designer must be clear about the overflow time of the watchdog to determine when appropriate. Qingmen
Dogs cannot be too frequent. Otherwise, resources will be wasted. When the program runs normally, the software sets the number of timers at a certain time (less than the timer overflow cycle) to prevent false reset caused by overflow interruption.
Dog use: the dog is used to restore the normal operation of the system and an effective monitoring manager (with the function of locking the optical drive and locking any specified program, it can be used in families to prevent children from playing games, surfing the Internet, watching videos, and so on.
System software "Watchdog" design ideas:
1. Set the watchdog timer T0. Set the T0 working mode in the initialization block, and enable the interrupt and count functions. System
System Fosc = 12 MHz, T0 is a 16-bit counter, and the maximum count value is (16 power of 2)-1 = 65
535, T0 input counting frequency is. Fosc/12, overflow cycle is (65 535 + 1)/1 = 65 536 (μs ).
2. Calculate the time consumed by one cycle of the master program. Considering the function modules and the number of cycles of the system
About 16.6 ms. The system sets the "Watchdog" timer T0 30 MS (T0 initial value is 65 536-30 000 = 35
536 ). Each cycle of the master program will refresh the initial value of T0. If the program enters an "endless loop" and T0 has an initial value of 30
If not refreshed within ms, the "Watchdog" timer T0 will overflow and request interruption.
3. Design the interrupt service program corresponding to T0 overflow. This subroutine only requires one instruction, that is, to write the "unconditional transfer" command to the interrupt vector address (000BH) corresponding to T0, and drag the computer back to the first line of the entire program, reinitialize the microcontroller and obtain the correct execution sequence
The watchdog also has potential harm to computers. If the software is encrypted and sent to a ring network (such as a school data center), it will cause each sending, and the two computers will be poisoned for one day at a time, and will continue to spread for a week. For example, the operating speed is too slow, the desktop background is changed, and the drawing software must be black and green. It also causes a few fewer files on each computer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.