📄 wdt.c
字号:
#include "def.h"
#include "option.h"
#include <string.h>
#include "k44.h"
#include "k44lib.h"
void Test_Wdt(void)
{
int i;
Uart_Printf("[]Watch dog timer test\n");
//Basic timer period: 20Mhz/ 2^13 / 256 = 9.537 Hz
//Watch dog timer period: 9.537/8 = 1.19 Hz
Uart_Printf("After completing a count down until 10, CPU will be reset by WDT.\n");
rBTCON=0x0003;
for(i=0;i<10;i++)
{
Delay(500);
rBTCON=0x0003; //not to make MCU reset during this while statement.
Uart_Printf("%d ",i);
}
//MCU will be reset after 0.840 sec after the last rBTCON access.
while(1); // wait until reset.
}
volatile int btCount;
void __irq IsrBasicTimer(void)
{
rINTPEND=~BIT_BT; //clear URXD pending bit
btCount++;
}
void Test_BasicTimerInt(void)
{
Uart_Printf("[]Basic timer interrupt test\n");
rBTCON=0xa503;
pISR_BT=(unsigned)IsrBasicTimer;
rINTMASK=BIT_BT;
btCount=0;
Uart_Printf("Wait 5 basic timer interrupts\n");
while(btCount<5);
rINTMASK=0;
Uart_Printf("Basic timer interrupt test O.K.\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -