hi
看门狗要怎么设置才能超时时间到之后马上复位,而不是进回调?我的代码如下,如果我现在不喂狗,就一次进入watchdogCallback
/* * ======== watchdogCallback ======== */
void watchdogCallback(uintptr_t watchdogHandle)
{ /* * If the Watchdog Non-Maskable Interrupt (NMI) is called, * loop until the device resets. Some devices will invoke * this callback upon watchdog expiration while others will * reset. See the device specific watchdog driver documentation * for your device. */ while (1)
{}
}
Watchdog_Handle watchdogHandle; Watchdog_Params params; uint32_t reloadValue; /* Call driver init functions */ Watchdog_init(); /* Configure the LED and button pins */ Watchdog_Params_init(¶ms); params.callbackFxn = (Watchdog_Callback) watchdogCallback; params.debugStallMode = Watchdog_DEBUG_STALL_ON; params.resetMode = Watchdog_RESET_ON; watchdogHandle = Watchdog_open(Board_WATCHDOG0, ¶ms); if (watchdogHandle == NULL) { /* Error opening Watchdog */ while (1) {} } /* * The watchdog reload value is initialized during the * Watchdog_open() call. The reload value can also be * set dynamically during runtime. * * Converts TIMEOUT_MS to watchdog clock ticks. * This API is not applicable for all devices. * See the device specific watchdog driver documentation * for your device. */
reloadValue = Watchdog_convertMsToTicks(watchdogHandle, TIMEOUT_MS); /* * A value of zero (0) indicates the converted value exceeds 32 bits * OR that the API is not applicable for this specific device. */ if (reloadValue != 0) { Watchdog_setReload(watchdogHandle, reloadValue); } /* Turn on Board_GPIO_LED0 and enable Board_GPIO_BUTTON0 interrupt */
Viki Shi:
回调函数是为了有些客户需要进行超时处理考虑的,比如说可以在里面清除中断flag,从而避免复位。如果没有清【回调函数里不做处理】,第二次超时时就会进入中断。
If reset is enabled in the Watchdog_Params and the Watchdog timer is allowed to time out again while the interrupt flag is still pending, a reset signal will be generated. To prevent a reset, Watchdog_clear() must be called to clear the interrupt flag and to reload the timer.Since the device is not reset on the first Watchdog timeout, the maximum time lapse between the time when the device gets locked up and the time when it is reset can be up to two Watchdog timeout periods.
更多说明请参考:dev.ti.com/…/_watchdog_c_c26_x_x_8h.html