Lesson 7: STM32F4 + Proteus + Independent Watchdog (IWDG)

1Introduction to the Independent Watchdog

The watchdog is a hardware timer whose main function is to forcibly reset the entire system when a software fault or program runaway occurs, allowing it to return to normal operation. It is an independent system that can continue to operate even if the main clock fails, thus ensuring high reliability.

The STM32F4 has two watchdog peripherals (independent and window) that can be used to detect and resolve faults caused by software errors; when the counter reaches a specified timeout value, it triggers an interrupt (only applicable to the window watchdog) or generates a system reset.

The Independent Watchdog (IWDG) is driven by its dedicated low-speed clock (LSI) and thus remains operational even when the main clock fails.

The window watchdog (WWDG) clock is provided by the APB1 clock after prescaling, and it detects abnormal delays or premature operations of the application through a configurable time window.

The IWDG is best suited for applications that require a watchdog to operate completely independently of the main program and have lower time precision requirements.

2How to Feed the Dog

Lesson 7: STM32F4 + Proteus + Independent Watchdog (IWDG)

From the clock perspective, the watchdog can only be LSI internal low-speed clock

Lesson 7: STM32F4 + Proteus + Independent Watchdog (IWDG)

3 Programming

void IWDG_Init(u8 prer,u16 rlr){         IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);//Enable write access to IWDG->PR and IWDG->RLR                  IWDG_SetPrescaler(prer);//Set IWDG prescaler          IWDG_SetReload(rlr);   //Set IWDG reload value          IWDG_ReloadCounter();//Reload                  IWDG_Enable();       //Enable watchdog} //Feed the independent watchdogvoid IWDG_Feed(void){         IWDG_ReloadCounter();//Reload}

4 Testing

Lesson 7: STM32F4 + Proteus + Independent Watchdog (IWDG)

In the case of not feeding the watchdog, the test results show continuous resets.

Lesson 7: STM32F4 + Proteus + Independent Watchdog (IWDG)

After adding the watchdog feed, it will no longer reset.

It is important to note that the feeding time must be quick; if there is too much delay, the watchdog may reset before it can be fed.

Lesson 7: STM32F4 + Proteus + Independent Watchdog (IWDG)

Leave a Comment