⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 watchdog.c

📁 This program shows how to configure the watchdog timer for the following chips: Atmel 80C51RA2 A
💻 C
字号:
/*------------------------------------------------------------------------------
watchdog.c : Sample Program that demonstrates the watchdog timer for the
following microcontrollers

Atmel Wireless & uC 80C51RA2
Atmel Wireless & uC 80C51RD2
Atmel Wireless & uC 80C54X2
Atmel Wireless & uC 80C58X2
Atmel Wireless & uC 83/87C51RB2
Atmel Wireless & uC 83/87C51RC2
Atmel Wireless & uC 83/87C51RD2
Atmel Wireless & uC T87C5111
Atmel Wireless & uC T87C5112
Atmel Wireless & uC T89C51AC2
Atmel Wireless & uC T89C51CC01
Atmel Wireless & uC T89C51CC02
Atmel Wireless & uC T89C51IB2
Atmel Wireless & uC T89C51IC2
Atmel Wireless & uC T89C51RB2
Atmel Wireless & uC T89C51RC2
Atmel Wireless & uC T89C51RD2

Copyright (c) 1988-2001 Keil Elektronik GmbH and Keil Software, Inc.
All rights reserved.
--------------------------------------------------------------------------*/

sfr  WDTRST  =   0xA6;			 
sfr  WDTPRG  =   0xA7;			 

/*------------------------------------------------------------------------------
rst_Watchdog() : Resets the watchdog timer to avoid microcontroller reset
				   This is done by writing to the WDTRST sfr with 0x1E and 
				   then 0xE1.  This will reset the timer to 0x0.
------------------------------------------------------------------------------*/
void rst_Watchdog( void )
{
	WDTPRG |= 0x07;
	WDTRST  = 0x1E;
    WDTRST  = 0xE1;
}

/*------------------------------------------------------------------------------
main() : Runs a while loop that simulated a condition that will cause the 
		 watchdog timer to reset the microcontroller.
------------------------------------------------------------------------------*/
void main( void )
{
	int i;

	// Sets the watchdog time to reset after 2^21 - 1 clock cycles 
	

	rst_Watchdog();
	
	//Reset Watchdog to ensure timer doesn't reset
	for( i = 0; i < 500; i++)
	{
		rst_Watchdog();
	}

	while(1)
	{
	  	//Simulating a error that would cause the watchdog timer to reset processor
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -