How to use 89S52 watchdog

Publisher:码农侠Latest update time:2016-09-22 Source: eefocusKeywords:89S52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
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.
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.
Keywords:89S52 Reference address:How to use 89S52 watchdog

Previous article:MCU Countdown Timer
Next article:C51 Storage Type

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号