通過讀取RSTFLAG標志來判斷也是可以的。
不過需要注意RSTFLAG是擴展寄存器,訪問前需要開啟擴展寄存器訪問使能。
if(RSTFLAG & 0x10) //LVDRSTF
{
RSTFLAG |= 0x10; //寫1清除標志位
printf("LVD reset.temp=%u\r\n",temp);
}
if(RSTFLAG & 0x08) //WDTRSTF
{
RSTFLAG |= 0x08; //寫1清除標志位
printf("Watchdog reset.temp=%u\r\n",temp);
}
if(RSTFLAG & 0x04) //SWRSTF
{
RSTFLAG |= 0x04; //寫1清除標志位
printf("Software reset.temp=%u\r\n",temp);
}
if(RSTFLAG & 0x02) //ROMOVF
{
RSTFLAG |= 0x02; //寫1清除標志位
printf("ROM Overflow reset.temp=%u\r\n",temp);
}
if(RSTFLAG & 0x01) //EXRSTF
{
RSTFLAG |= 0x01; //寫1清除標志位
printf("External reset.temp=%u\r\n",temp);
}
串口驗證復位來源.zip
(7.46 KB, 下載次數: 1)
2024-4-19 11:13 上傳
點擊文件名下載附件
|