在线时间7 小时
UID421931
注册时间2013-3-19
NXP金币0
该用户从未签到
中级会员
 
- 积分
- 278
- 最后登录
- 1970-1-1
|
能帮我看一下,为什么调用后还是COP复位?
#define EnableInterrupts asm(" CPSIE i");
#define DisableInterrupts asm(" CPSID i");
/********************************************************************/
/*
* Watchdog timer disable routine
*
* Parameters:
* none
*/
void wdog_disable(void)
{
/* First unlock the watchdog so that we can write to registers */
wdog_unlock();
/* Clear the WDOGEN bit to disable the watchdog */
WDOG_STCTRLH &= ~WDOG_STCTRLH_WDOGEN_MASK;
}
void wdog_enable(void)
{
/* First unlock the watchdog so that we can write to registers */
wdog_unlock();
WDOG_STCTRLH |= WDOG_STCTRLH_WDOGEN_MASK;
}
/********************************************************************/
/*
* Watchdog timer unlock routine. Writing 0xC520 followed by 0xD928
* will unlock the write once registers in the WDOG so they are writable
* within the WCT period.
*
* Parameters:
* none
*/
void wdog_unlock(void)
{
/* NOTE: DO NOT SINGLE STEP THROUGH THIS FUNCTION!!! */
/* There are timing requirements for the execution of the unlock. If
* you single step through the code you will cause the CPU to reset.
*/
/* This sequence must execute within 20 clock cycles, so disable
* interrupts will keep the code atomic and ensure the timing.
*/
DisableInterrupts;
/* Write 0xC520 to the unlock register */
WDOG_UNLOCK = 0xC520;
/* Followed by 0xD928 to complete the unlock */
WDOG_UNLOCK = 0xD928;
/* Re-enable interrupts now that we are done */
EnableInterrupts;
}
/********************************************************************/
void wdog_init(void)
{
// 解锁
wdog_unlock();
// 预分频 PRESCVAL = 4, Wdog colck = BUS/(4+1) = 15M
WDOG_PRESC = 0x0400;
// 2秒
WDOG_TOVALH = 0x01C9;
WDOG_TOVALL = 0xC380;
// 使能总线,静止窗口模式,禁止看门口中断,开启开门狗
WDOG_STCTRLH = 0x01D3;
}
void wdog_feed(void)
{
// 解锁
wdog_unlock();
// PRESCVAL = 4, Wdog colck = BUS/(4+1) = 15M
WDOG_PRESC = 0x0400;
WDOG_REFRESH = 0xA602;
WDOG_REFRESH = 0xB480;
}
|
|