This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于看门狗使用的问题



看门狗如果使用后,计数到0就触发软件复位,那如果软件正常运行,我要怎么样和普通单片机一样清看门狗呢?

  • 你可以调用看门狗的库函数wdogFeed( )进行清狗操作。

     

  • 补充一下,在喂狗操作时,需要解除看门狗锁定

    喂狗操作的代码如下:

    WatchdogUnlock(WATCHDOG_BASE); // 解除锁定

    WatchdogIntClear(WATCHDOG_BASE); // 即喂狗操作

    WatchdogLock(WATCHDOG_BASE); // 重新锁定

  • 为什么在232的看门狗例程中不需要解锁和重新锁定的语句

    void
    WatchdogIntHandler(void)
    {
        //
        // If we have been told to stop feeding the watchdog, return immediately
        // without clearing the interrupt.  This will cause the system to reset
        // next time the watchdog interrupt fires.
        //
        if(!g_bFeedWatchdog)
        {
            return;
        }

        //
        // Clear the watchdog interrupt.
        //
        ROM_WatchdogIntClear(WATCHDOG0_BASE);

        //
        // Invert the GPIO PF3 value.
        //
        ROM_GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2,
                         (ROM_GPIOPinRead(GPIO_PORTG_BASE, GPIO_PIN_2) ^
                                         GPIO_PIN_2));
    }

  • 默认情况下,看门狗是没有上锁的。

    如果配置时使用了WatchdogLock函数,则在喂狗时需要先解锁。