The 89S52 and 89C51 in ATMEL's 89S52 series have the same functions. The instructions are compatible. HEX programs can be used directly without any conversion. The 89S52 has a watchdog function compared to the 89C51. For other functions of the 89S52, please refer to the 89C52 data.
The specific use of the watchdog is as follows:
In the program initialization, 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 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;
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.
Keywords:89S52
Reference address:How to use 89S52 watchdog
The specific use of the watchdog is as follows:
In the program initialization, write 01EH first and then write 0E1H to the watchdog register (WDTRST address is 0A6H). The watchdog can be activated.
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
}
}
{
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:MCU Countdown Timer
Next article:C51 Storage Type
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- 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)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- 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
Guess you like
- E22-400TBL-01 LoRa module test version + 02 initial test
- Why? The 32768 in MSP430F2001 does not oscillate
- About the IP address routing of the WiFi module
- DSP2812 code is blocked by compiler problem
- DSP TMS320F28335 interrupt vector table
- (3) UART DMA plus IDLE interrupt indefinite length byte reception
- This positioning hole and via are the same as repairing a building.
- SVPWM control of sensored BLDC cannot start when fixed sector 5
- TMS570 Learning 1- Creating Engineering Lighting
- Arteli AT32 WB415 Bluetooth function development help