STM32单片机的看门狗问题

2019-08-16 20:58发布

看门狗初始化,溢出时间是6.4ms
#include "iwdg.h"
void InitIWDG(void)
{
        IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
        IWDG_SetPrescaler(IWDG_Prescaler_256);               // 40K/256=156HZ(6.4ms)
        IWDG_SetReload(1250);                                           // 1250 = 8s/6.4ms
        IWDG_ReloadCounter();       // Î11·
        IWDG_Enable();
}
如果下面的程序中的延时时间为2000ms,来一次喂狗,岂不是还没延时完成就已经看门狗复位了?

void PowerOFFPhone(void)
{
        GPIO_WriteBit(GPIOB, RestPhone, Bit_RESET);
        SoftDelayms(2000);
        IWDG_ReloadCounter();
        SoftDelayms(2000);
        IWDG_ReloadCounter();
        SoftDelayms(2000);
        IWDG_ReloadCounter();
        SoftDelayms(2000);
        IWDG_ReloadCounter();
        SoftDelayms(2000);
        IWDG_ReloadCounter();
        SoftDelayms(1000);
        IWDG_ReloadCounter();
        GPIO_WriteBit(GPIOB, RestPhone, Bit_SET);
        BKP_WriteBackupRegister(BKP_DR1, 0X0000);    // phone off state
}


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。