Watch Dog for learning by using lpc2103

Source: Internet
Author: User

In the evening, I learned the dog of the lpc2103.

Overview of the watchdog:

The watchdog includes a 4-frequency pre-divider and a 32-bit counter. The clock enters the timer through the pre-divider, And the timer declines (which is different from other timers ). The minimum value of the timer decrease is 0xff, that is, if you set a value smaller than 0xff, the system will load the timer as 0xff. Therefore, the minimum interval of the watchdog is (tpclk x 4x256), and the maximum interval is (tpclk x 2 to the power of 32x4 ). The use of the watchdog is as follows:

1. Set the fixed Loading Value of the watchdog timer in the wdtc register.

2. Set the mode in the wdmod register.

3. Enable the watchdog by writing 0xaa and 0x55 to the wdfeed register sequentially.

4. Feed the dog again before the watchdog counter overflows down to prevent reset interruption.

When the watchdog timer overflows downward, the program counter starts to run from 0x00000000, just like the external reset. Check the watchdog timeout sign (wdtof) to determine whether the watchdog generates Reset conditions. Wdtof must be cleared by software. It is the internal structure of the watchdog.

Next we will introduce the registers related to the watchdog.

Wdmod register

The watchdog operation is controlled by the wden bit and wdreset bit.

Note that once wden and wdreset are set. You cannot use the software to clear it. The two flags must be cleared by the external reset and the watchdog timer overflow. In addition, you can set wden to only enable wdt, but wdt is not started. The first time you feed the dog, you can start wdt.

Wdtof watchdog times out, And the watchdog time-out Mark is set, which is cleared by the software.

The wdint watchdog times out, And the watchdog interrupt flag is set. Any resetting will make this bit zeroing unavailable. Therefore, when a watchdog is interrupted, it can only be returned by forbidding the watchdog from being interrupted.


Wdtc register:

The wdtc Register determines the watchdog timeout value. When the dog feed sequence is generated, the content of wdtc is reloaded into the watchdog timer. It is a 32-bit timer with a minimum value of 0xff.


Wdfeed register:

Write 0xaa to the register, and then write 0x55 to reload the wdtc value into the watchdog timer. If the watchdog is enabled through wdmod, this operation also starts the watchdog to run. A proper dog feeding sequence must be completed before the watchdog overflows. If the second pclk cycle is incorrect after the dog timing is fed, the reset/interrupt of the watchdog is triggered.

Wdtv register:

The wdtv register is used to read the current value of the current watchdog timer.

Finally, we will explain the interruption of the watchdog.

As long as wdt is started, wdt will not stop. Moreover, after wdt overflows, it will trigger the interruption, which is the relationship between the wdt interrupt and the vector interrupt controller.

It must be noted that the wdt interrupt flag cannot be cleared through the software, and can only be reset and cleared by the hardware. Therefore, when a wdt interrupt occurs, the result can only be returned by disabling the wdt interrupt.

The above is the lpc2103 watchdog. See easyarm2103

Improve every day.

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.