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.