Correct watchdog usage

Source: Internet
Author: User

Watchdog should be familiar with those who have experience in MCU learning. However, if watchdog is used correctly, I am afraid you will not have a deep understanding of the actual product development.

The ressa rl78 series microcontroller has its own watchdog. When the watchdogtimer timer is enabled, 75% of the watchdog timer overflow interval will interrupt the watchdog. As for what to do in watchdog, many sample programs will feed the dog in the interrupt processing function, so that watchdog timer can start timing again.

Should the actual dog feeding program be In the watchdog interrupt handler? If so, what is the effect? If not, where should the dog Feed program be placed and what should be done in the interrupt processing function? The answer is as follows.

If the dog Feed program is only in the watchdog interrupt processing function, of course, the purpose of restarting watchdog timer is achieved, and the reset caused by watchdogtimer overflow is also avoided. However, the value of watchdog itself has been lost. The existence of watchdog indicates the illegal loop in the monitoring program and whether the program runs. Assume that the program is already in an invalid loop and cannot exit, or the program is already running. The Timed Interruption of watchdog timer still works properly, so the dog feeding program can still run normally. After the interrupt function is executed, the return points of the program are still invalid loops or illegal commands that run and fly. In this case, you can write programs in other MCU to break the breakpoint for debugging.

Since the dog Feed program cannot be placed in the timed interrupt of watchdogtimer, where should it be placed. First of all, for a forward migration of knowledge, the scheduled interrupt execution mechanism of watchdog timer is the mechanism followed by all interruptions. The dog fed in the interrupt processing function cannot achieve the goal, of course, the same applies to other scheduled interrupt processing functions. The proper dog feeding program needs to be put into the main loop of the main function. The time interval between dog feeding needs to consider the one with the largest time consumption for all possible branches of the main loop. That is, the overflow time of watchdog timer is greater than the maximum time consumed by all branches, and the feeding interval is less than the maximum time consumed by all branches.

Return to the last question. What should the watchdog timer interrupt processing program do? Like the common timer, it provides a more precise timing interval. For example, in the migration of ucosii to rl78/G14, watchdog timer can be periodically interrupted as the clock cycle of the operating system.

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.