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

📄 watchdog2.c

📁 ADuC系列芯片的源代码事例
💻 C
字号:
/*********************************************************************

 Author        : ADI - Apps            www.analog.com/MicroConverter

 Date          : Sept. 2005

 File          : Watchdog2.c

 Hardware      : Applicable to ADuC702x rev H or I silicon
                 Currently targetting ADuC7026.

 Description   : This example demonstrates the use of the  watchdog timer in secure mode
 				 - on the four first occurences the timer is refreshed/reloaded on time
				  with the correct seed
				 - on the fifth occurence:
				 OPTION 0: the seed is incorrect, the timer resets the part straigh away.
				 OPTION 1: code is delayed, the timer will time out before resetting the part. 
		
*********************************************************************/
#include<ADuC7026.h>


/*------------ options ------------
OPTION=0: incorrect seed
OPTION=1: too late
----------------------------------------------*/
#define OPTION 0                       



void delay (int length)
{
	while (length >=0)
    	length--;
}

char seed;
char poly = 0xB1;

void delay(int);


int main(void)				
{
char i;
seed = 0xAA;					// Setting seed initial value

GP4DAT = 0x04000000;			// P4.2 configured as an output. LED is turned on	
GP1DAT = 0x01000000;			// P1.0 as output

T3CLRI = seed;
delay(0x10);						 
T3LD = 0x1000;			  		// 0x1000/32768 = 125ms
T3CON = 0xF0;    	  			// IRQ instead of reset, for test purposes only

while (1)
	{

	for (i=0;i<4;i++){
		delay (0x1000);		 	// 2ms
		T3CLRI = seed;
		GP4DAT ^= 0x00040000;
		if ((seed & 0x80)==0x80) seed = ((seed ^ poly)<<1) + 1 ; // Generating next seed... 
		else seed = (seed <<1);									 // ...value in sequence
		}

	if (OPTION == 0) T3CLRI = 0x00;		// Not part of sequence, will cause immediate reset.
	
	if (OPTION == 1){					// Delay greater than Timer3 value so will cause reset
		delay(0x80000);	  		
		T3CLRI = seed;
	}

	}				
}

⌨️ 快捷键说明

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