看门狗的初始化、启动、喂狗函数已经写好,已经加入到主程序中具体请见最后代码。
碰到的情况是在minipro 编程器里选中WDT使能,lpc936就无法运行起来。
禁止WDT功能,lpc936就能正常运行(当然没有看门狗功能)。
请问该怎么调整,谢谢。
/***********************************************************************
MODULE: Watchdog
VERSION: 1.01
CONTAINS: Routines for controlling the Watchdog on the
P89LPC922
COPYRIGHT: Embedded Systems Academy, Inc. - www.esacademy.com
LICENSE: May be freely used in commercial and non-commercial code
without royalties provided this copyright notice remains
in this file and unaltered
WARNING: IF THIS FILE IS REGENERATED BY CODE ARCHITECT ANY CHANGES
MADE WILL BE LOST. WHERE POSSIBLE USE ONLY CODE ARCHITECT
TO CHANGE THE CONTENTS OF THIS FILE
GENERATED: On "May 25 2007" at "08:43:39" by Code Architect 2.11
***********************************************************************/
// SFR description needs to be included
#include <reg922.h>
// #include "watchdog.h"
/***********************************************************************
DESC: Initializes the watchdog as a Watchdog Timer
Uses Watchdog clock at 400kHz as a clock source
Resets the device if not fed within 998.888 ms
RETURNS: Nothing
************************************************************************/
void watchdog_init (void)
{
bit eacopy;
// init reload value and prescaler
// select Watchdog clock at 400kHz
// start watchdog
WDL = 0xFF;
eacopy = EA;
EA = 0;
WDCON = 0xC1;
WFEED1 = 0xA5;
WFEED2 = 0x5A;
EA = eacopy;
}
/***********************************************************************
DESC: Feeds the Watchdog to stop the device from resetting
RETURNS: Nothing
CAUTION: watchdog_init must be called first
************************************************************************/
void watchdog_feed (void)
{
bit eacopy;
// disable interrupts
eacopy = EA;
EA = 0;
// feed the watchdog
WFEED1 = 0xA5;
WFEED2 = 0x5A;
// restore interrupts
EA = eacopy;
}
/***********************************************************************
DESC: Starts the Watchdog
RETURNS: Nothing
CAUTION: watchdog_init must be called first
************************************************************************/
void watchdog_start (void)
{
bit eacopy;
// disable interrupts
eacopy = EA;
EA = 0;
// start the watchdog
WDCON |= 0x04;
// feed the watchdog
WFEED1 = 0xA5;
WFEED2 = 0x5A;
// restore interrupts
EA = eacopy;
}
/***********************************************************************
DESC: Stops the Watchdog
RETURNS: Nothing
CAUTION: watchdog_init must be called first
************************************************************************/
void watchdog_stop (void)
{
bit eacopy;
// disable interrupts
eacopy = EA;
EA = 0;
// stop the watchdog
WDCON &= ~0x04;
// feed the watchdog
WFEED1 = 0xA5;
WFEED2 = 0x5A;
// restore interrupts
EA = eacopy;
}
|