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

📄 watchdog_test.c

📁 基于S3C2410的看门狗例程 想熟悉看门狗的人进
💻 C
字号:
/*********************************************************************************************
* File:	watchdog_test.c
* Author:	embest
* Desc:	c main entry
* History:	
*			
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/*                                     include files	                                    */
/*------------------------------------------------------------------------------------------*/
#include "2410lib.h"

/*------------------------------------------------------------------------------------------*/
/*               global varibles and interrupte service routine declare                     */
/*------------------------------------------------------------------------------------------*/
void  __irq watchdog_int(void) ;//__attribute__((interrupt ("IRQ")));
INT8T f_ucSecondNo;

/*------------------------------------------------------------------------------------------*/
/*                                   function code	                                    */
/*------------------------------------------------------------------------------------------*/
/*********************************************************************************************
* name:		watchdog_test
* func:		watchdog timer test function
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void watchdog_test(void)
{	f_ucSecondNo = 0;
    uart_printf("\n WatchDog Timer Test Example\n");
	uart_printf(" 10 seconds:\n");
    rSRCPND|=0x0200;
    rINTPND|=0x200;
	//ClearPending(BIT_WDT);						// clear interrupt pending bit
	pISR_WDT = (unsigned)watchdog_int;				// Initialize WDT interrupt handler entry
	rWTCON = ((PCLK/1000000-1)<<8)|(3<<3)|(1<<2);	// 1M,1/128, enable interrupt
	rWTDAT = 7812;									// 1M/128=7812
	rWTCNT = 7812;
	rWTCON = rWTCON & ~1;
    //rWTCON = rWTCON | 1;                  		// enable restart                 
	rWTCON |=(1<<5);								// start watchdog timer
	
	rINTMOD &= ~(BIT_WDT);
	rINTMSK &= ~(BIT_WDT);
	while((f_ucSecondNo)<11);
	rINTMSK |= BIT_WDT;								// mask watchdog timer interrupt
	uart_printf(" end.\n"); 	 
}

/*********************************************************************************************
* name:		watchdog_int
* func:		watchdog interrupt service routine
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void __irq watchdog_int(void)
{
	ClearPending(BIT_WDT);
	f_ucSecondNo++;	
	if(f_ucSecondNo<11)
		uart_printf(" %3ds ",f_ucSecondNo);
	else
		uart_printf("\n O.K.");
}

⌨️ 快捷键说明

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