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

📄 watchdog_test.c

📁 Embest EudKit-II教学系统配Samsung S3C44B0处理器的部分测试程序。
💻 C
字号:
/*********************************************************************************************
* File:	watchdog_test.c
* Author:	embest
* Desc:	watchdog_test source code
* History:	
*********************************************************************************************/
#include "44b.h"
#include "44blib.h"

/*------------------------------------------------------------------------------------------*/
/*	 								global variables					 				    */
/*------------------------------------------------------------------------------------------*/
volatile int f_nWdtIntnum; 

/*------------------------------------------------------------------------------------------*/
/*	 								function declare					 				    */
/*------------------------------------------------------------------------------------------*/
void wdtimer _test(void);
void wdt_int(void);// __attribute__ ((interrupt ("IRQ")));

/*********************************************************************************************
* name:		Main
* func:		c code entry
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void Main(void)
{
	sys_init();												// Initial 44B0X's Interrupt,Port and UART
 	uart_printf("\n\r Embest Arm EduKit II Evaluation Board\n");
	
	wdtimer _test();											// test start	
}


/*********************************************************************************************
* name:		wdtimer _test
* func:		Test the interrupt function and reset function in watdch-dog
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void wdtimer _test(void)
{
    
	uart_printf("\n\r WatchDog Timer Test Example\n");
	// Enable interrupt
	rINTMSK = ~(BIT_GLOBAL | BIT_WDT);						// enable interrupt 
	pISR_WDT = (unsigned)wdt_int;							// set WDT interrupt handler 
	f_nWdtIntnum = 0;
   
	//test interrupt function
	rWTCON = ((MCLK/1000000-1)<<8) | (3<<3) | (1<<2);		// nWDTCountTime = 1/64/128, interrupt enable
	rWTDAT = 7812;											// 1s = 7812 * nWDTCountTime
	rWTCNT = 7812;
	rWTCON = rWTCON | (1<<5);								// Enable Watch-dog timer 
   
	while( f_nWdtIntnum != 10); 
    
	//test reset function
	rWTCON = ((MCLK/1000000-1)<<8) | (3<<3) | (1);			// 1/66/128, reset enable
	uart_printf("\nI will restart after 5 sec!!!\n");
	rWTCNT = 7812*5;										// waiting 5 seconds
	rWTCON = rWTCON | (1<<5);								// Enable Watch-dog timer 
	while(1);
	
	rINTMSK = BIT_GLOBAL;
}

/*********************************************************************************************
* name:		wdt_int
* func:		wdt interrupt handler
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void  wdt_int(void)
{
	rI_ISPC = BIT_WDT;
	uart_printf("%d ",++f_nWdtIntnum);
}

⌨️ 快捷键说明

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