我的看门狗初始化如下:
void WCOP_Init( void )
{
// Disable protection of clock-source register
CPMUPROT = 0x26U;
// COP disable during pseudo-stop mode
CPMUCLKS_PCE = 0;
// Clock select: Internal clock
CPMUCLKS_COPOSCSEL = 0;
// Re-Enable protection of clock-source register
CPMUPROT = 0x00;
// Normal COP operation
// Allows the COP and RTI to keep running in Active BDM mode
// Time-out period prescaler:6
// Time-out period 2^23 = 8388ms
CPMUCOP = 0x06;
}
中断服务程序如下:
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 2 WCOP_Interrupt( void )
{
//没有停在这里,而是直接复位
while(1);
_asm jmp _EntryPoint;
}
#pragma CODE_SEG DEFAULT
2.还有一个问题,我怎么可以在复位后检测是不是看门狗复位呢?没有这个标志位
PE生成的代码,我很奇怪为什么是不是看门狗复位和CPMURTI 寄存器有什么关系
if (CPMURTI != 0x00U) { /* CPMURTI register is set to zero after reset. */
LastResetSource = CPMURTI; /* WatchDog or Clock monitor reset enrty points sets this register to non-zero value */
} else if (CPMUFLG_ILAF == 0x01U) { /* Illegal Address Reset? */
LastResetSource = CPU_ILLEGAL_ADDRESS_RESET; /* Store reset reason to the temporary location */
} else if (CPMUFLG_PORF == 0x01U) { /* Power on Reset? */
LastResetSource = CPU_POWER_ON_RESET; /* Store reset reason to the temporary location */
} else if (CPMUFLG_LVRF == 0x01U) { /* Low Voltage Reset? */
LastResetSource = CPU_LVI_RESET; /* Store reset reason to the temporary location */
} else { /* (!testReg8Bit(CRGFLG, LVRF)) */
/* External Reset */
LastResetSource = CPU_EXTERNAL_RESET; /* Store reset reason to the temporary location */
}