?? watchdog2.c
字號(hào):
/*********************************************************************
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); // 0.35ms
T3LD = 0x1000; // 125ms
T3CON = 0xF0; // IRQ instead of reset, for test purposes only
while (1)
{
for (i=0;i<4;i++){
delay (0x30000);
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(0xA0000); // > 125ms and so will cause a reset.
T3CLRI = seed;
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -