The specific usage of the watchdog is as follows:
in the program initialization, first write 01EH and then write 0E1H to the watchdog register (WDTRST address is 0A6H). This activates the watchdog.
code
org 0000
Ljmp begin
Begin:
Mov 0A6H,#01EH ;Send 1E first
Mov 0A6H,#0E1H ;Send E1 later
;Activate the watchdog in program initialization.
……
……
For:
……
Mov 0A6H,#01EH ;Send 1E first
Mov 0A6H,#0E1H ;Send E1 later
;Feed the watchdog instruction
……
Ljmp for
In C language, add a declaration statement.
Add a line sfr WDTRST = 0xA6 in the AT89X51.h declaration file;
code
Main()
{
WDTRST=0x1E;
WDTRST=0xE1; //Initialize the watchdog.
While (1)
{
WDTRST=0x1E;
WDTRST=0xE1; //Feed the watchdog
}
}
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 . When the crystal oscillator stops oscillating, the watchdog is also invalid.
3. 89S51 has only a 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 needs to be fed once every 16 milliseconds.
Previous article:Introduction to reset circuit and watchdog circuit
Next article:Light up the running lights with C programming language
Recommended ReadingLatest update time:2024-11-15 07:30
- 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
- [New Year's Flavor Competition] Northeast New Year's Eve Dinner is Coming
- TMS320F28335 project development record 9_28335 interrupt system
- Dealing with Rejection Issues: PSRR vs. CMRR of Instrumentation Amplifiers
- Common protection circuits for switching power supplies - overheating, overcurrent, overvoltage and soft start protection circuits
- [Lazy self-care fish tank control system] BLE_MESH network test, multiple elements are not allowed
- Detailed explanation of MSP430 crystal oscillator configuration
- C8051F340 program runaway problem
- Knowledge points on the classification of commonly used components in RF microwave circuits
- Tektronix TBS2000B Oscilloscope
- Safety issues regarding multi-port USB chargers on the market