wdt.c

来自「这是s3c3v40开发板自带的光盘定时器实验程序源代码」· C语言 代码 · 共 39 行

C
39
字号
#include "44b.h"
#include "44blib.h"
#include "timer.h"

volatile int isWdtInt;
void Wdt_Int(void) __attribute__ ((interrupt ("IRQ")));

/****************************************
 *	Watch-dog timer test		*
 ****************************************/
void Test_WDTimer(void)
{
    Uart_Printf("<---- WatchDog Timer Test ---->\n");

    rINTMSK=~(BIT_GLOBAL|BIT_WDT);
    pISR_WDT=(unsigned)Wdt_Int;
    isWdtInt=0;
	
    rWTCON=((MCLK/1000000-1)<<8)|(3<<3)|(1<<2);  //  t_watchdog = 1/66/128, interrupt enable
    rWTDAT=8448/4;
    rWTCNT=8448/4;
    rWTCON=rWTCON|(1<<5);   // 1/40/128,interrupt 

    while(isWdtInt!=10);

    rWTCON=((MCLK/1000000-1)<<8)|(3<<3)|(1);  //   1/66/128, reset enable
    Uart_Printf("\nI will restart after 2 sec!!!\n");
    rWTCNT=8448*2;
    rWTCON=rWTCON|(1<<5);   // 1/40/128,interrupt 
    while(1);
    rINTMSK|=BIT_GLOBAL;
}

void Wdt_Int(void)
{
    rI_ISPC=BIT_WDT;
    Uart_Printf("%d ",++isWdtInt);
}

⌨️ 快捷键说明

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