?? main.c
字號(hào):
#include <reg51f.h>
/*------------------------------------------------
This function adjusts the watchdog timer compare
value to the current PCA timer value + 0xFF00.
Note that you must write to CCAP4L first, then
write to CCAP4H.
------------------------------------------------*/
void watchdog_reset (void)
{
unsigned int newval;
newval = (CH << 8) | CL;
newval += 0xFF00;
CCAP4L = newval;
CCAP4H = newval >> 8;
}
/*------------------------------------------------
MAIN C function
------------------------------------------------*/
void main (void)
{
unsigned int i;
/*--------------------------------------
Configure PCA Module 4 as the watchdog
and make sure it doesn't time-out
immediately.
--------------------------------------*/
watchdog_reset ();
CCAPM4 = 0x48;
/*--------------------------------------
Configure the PCA for watchdog timer.
--------------------------------------*/
CMOD = (CMOD & 0x01) | 0x40;
/*--------------------------------------
Start the PCA Timer.
From this point on, we must reset the
watchdog timer every 0xFF00 clock
cycles. If we don't the watchdog timer
will reset the MCU.
--------------------------------------*/
CR = 1;
/*--------------------------------------
Do something for a while and make sure
that we don't get reset by the watchdog.
--------------------------------------*/
for (i = 0; i < 1000; i++)
{
watchdog_reset ();
}
/*--------------------------------------
Stop updating the watchdog and we should
get reset.
--------------------------------------*/
while (1)
{
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -