The usage of 89S51 watchdog function is as follows:
In the initialization of the program, write 01EH first and then write 0E1H to the watchdog register (WDTRST address is 0A6H). The watchdog can
be activated .
Org 0000
Ljmp begin
Begin:
Mov 0A6H,#01EH; send 1E first
Mov 0A6H,#0E1H; send E1 later
; Activate the watchdog in the program initialization.
……
……
For:
……
Mov 0A6H,#01EH ;Send 1E first
Mov 0A6H,#0E1H ;Send E1 later
;Feed the dog instruction
……
Ljmp for
In C language, a declaration statement must be added.
Add a line in the AT89X51.h declaration file sfr WDTRST = 0xA6;
Main()
{
WDTRST=0x1E;
WDTRST=0xE1;//Initialize the watchdog.
While (1)
{
WDTRST=0x1E;
WDTRST=0xE1;//Feed the dog instruction
}
}
Notes:
1. The watchdog of 89S51 must be activated by the program before it starts working. Therefore, it is necessary to ensure that the CPU has a reliable power-on reset.
Otherwise, the watchdog will not work.
2. The watchdog uses the crystal oscillator of the CPU . The watchdog is also invalid when the crystal oscillator stops.
3. 89S51 has only 14-bit counter. The watchdog must be fed at least once in 16383 machine cycles . And this time is
fixed and cannot be changed. When the crystal oscillator is 12M, the watchdog must be fed once every 16 milliseconds.
The timer can also be used to extend the watchdog feeding time from a few seconds to a few minutes.
In general, a dedicated watchdog chip is used.
Previous article:51 MCU and USB chip PDIUSBD12 interface firmware program
Next article:2864LCD display remote control key value decoder
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- PCB design experience - for reference
- Confused, what is an oscilloscope with a Z axis? Don't worry, here is an introduction
- Wireless communication, 5G, RF, antenna and several concepts and indicators
- Happy Lantern Festival! Guess the lantern riddles and have fun
- How to make an automatic switch when there are 3 5V input ports on a circuit board?
- "Operational Amplifier Parameter Analysis and LTspice Application Simulation" Reading Notes Part 3 - Noise
- 280 million yuan in subsidies returned! A Russian supercomputer company's self-developed CPU failed to meet the standards and was sued by the Ministry of Industry and Trade
- I have a question about the drive circuit.
- Oh my god! My air conditioner has become a spirit!
- Analysis of the problem that the program cannot run after F28004x online debugging reset