📄 watchdog_test.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 watchdog_int(void) __attribute__((interrupt ("IRQ")));
static volatile INT8T f_ucSecondNo;
/*------------------------------------------------------------------------------------------*/
/* function code */
/*------------------------------------------------------------------------------------------*/
/*********************************************************************************************
* name: watchdog_test
* func: watchdog timer test function
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void watchdog_test(void)
{
uart_printf("\n WatchDog Timer Test Example\n");
uart_printf(" 10 seconds:\n");
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 |=(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 watchdog_int(void)
{
UINT8T szBuf[10];
ClearPending(BIT_WDT);
f_ucSecondNo++;
if(f_ucSecondNo<11)
sprintf(&szBuf,"%ds",f_ucSecondNo);
else
sprintf(&szBuf, "O.K.");
#ifdef BOARDTEST
print_lcd(200,170,0x1c,&szBuf);
#endif
uart_printf(szBuf);
uart_printf("\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -