最近在调试 EFM32PG22 系列的芯片,在调试串口的时候,偶发串口中断接收不到完整的数据,
竟然发现该芯片自带的“喂狗”功能大有文章
__STATIC_INLINE void WDOG_Feed(void) ;
CORE_DECLARE_IRQ_STATE;
if ((wdog->EN & WDOG_EN_EN) == 0U) {
return;
}
CORE_ENTER_ATOMIC();
if ((wdog->SYNCBUSY & WDOG_SYNCBUSY_CMD) == 0U) {
wdog->CMD = WDOG_CMD_CLEAR;
}
CORE_EXIT_ATOMIC();
其中 CORE_ENTER_ATOMIC(); 中含有 __disable_irq();
喂狗完毕 __enable_irq();
而且 根据 函数的介绍
When using the ULFRCO for instance as the oscillator the watchdog runs on a 1 kHz clock
and a watchdog clear operation might take up to 4 ms.
也就是喂狗期间 总中断关闭长达 4ms