#include "bat32g137.h"
#include "EventRecorder.h" // Keil.ARM Compiler::Compiler:Event Recorder
#include "stdio.h"
// 看門狗時鐘源爲15K的 fil
uint32_t i;
int main(void)
{
SystemCoreClockUpdate();
EventRecorderInitialize(0,0);
EventRecorderStart();
PORT->PM0 &= ~(1<<5);
PORT->PMC0 &= ~(1<<5);
while(1)
{
}
}
void NMI_Handler(void)
{
//printf("wdt = %08ld\n",i++);
WDT->WDTE = 0xACU; /* restart watchdog timer */
if(PORT->P0 & (1<<5))
{
PORT->P0 &= ~(1<<5);
EventStartA(0);
}
else
{
PORT->P0 |= (1<<5);
EventStopA(0);
}
}
1.看門狗使用的時鐘源爲內部的低速時鐘15K
2.看門狗中斷入口爲NMI,這個很特別。
3.注意75% 是開啓窗口看門狗功能,如果在溢出時間75% 以內復位看門狗計數器就會造成復位。
100% 隨時都可以復位看門狗,可以理解沒有窗口看門狗功功能。