How to Use the 51 watchdog function

Source: Internet
Author: User

The serial 51 in ATMEL has the same functions as 89C51. Command compatibility. The hex program does not require any conversion.
Directly. Listen 51 only adds a watchdog function than 89C51. For other functions of iis51, refer to 89C51.
.
The use of the watchdog is as follows:
In program initialization, first write 01eh to the watchdog register (wdtrst address is 0a6h) and then 0e1h. Exciting
Active guard.
Org 1, 0000
Ljmp begin
Begin:
MoV 0a6h, # 01eh; send 1E first
MoV 0a6h, # 0e1h; then E1
To activate the watchdog during program initialization.
......
......
For:
......
MoV 0a6h, # 01eh; send 1E first
MoV 0a6h, # 0e1h; then E1
Dog feed command
......
Ljmp

Add a statement in C.
Add a line SFr wdtrst = 0xa6 in the at89x51. h declaration file;
Main ()
{
Wdtrst = 0x1e;
Wdtrst = 0xe1; // initialize the watchdog.
While (1)
{
Wdtrst = 0x1e;
Wdtrst = 0xe1; // dog Feed command

}
}

Note:
1. the watchdog of listen 51 must be activated by the program before it starts to work. Therefore, you must ensure that the CPU has a * power-on reset.
Otherwise, the watchdog cannot work.
2. The Watchdog uses the crystal oscillator of the CPU. When the crystal oscillator stops running the neon baking system, how does it affect fenqi? BR> 3. 51 has only 14 counters. The dog must be fed at least once in 16383 machine cycles. And the time is solid.
Fixed, cannot be changed. When the crystal oscillator is 12 m, the dog needs to be fed every 16 milliseconds.
I have already debugged the above program. The timer is also used to extend the dog's feeding time by several seconds to several minutes.

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.