 Hello and welcome to the STM32L4 MOOC online training. My name is André Barata and I'll guide you through the independent watchdog hands-on session. IWDGs tends for independent watchdog. The independent watchdog is used to detect and resolve malfunctions due to the software failure. It triggers a reset sequence when the counter reaches its timeout value. The name of the peripheral refers to the feature working independently on the system clock. And thus it remains active even if the main clock fails. The low-speed internal oscillator is used for clocking this peripheral. Once enabled, it cannot be disabled except for a reset. The independent watchdog is clocked directly from the low-speed internal oscillator. Therefore, when the MCU enters a low power mode, the application still has to be refreshed on a regular basis. If application restrictions do not allow to do that, the application can make use of an option byte which allows to freeze the watchdog in stop, standby and shutdown low power modes. The peripheral can be started either by software or by hardware when a dedicated option byte is configured accordingly. Once enabled, it cannot be disabled except for a power-on reset. Here we can see a block diagram of the independent watchdog peripheral. The reset is generated when the 12-bit down counter underflows. It also features the possibility to be used in window mode. And as you know, the peripheral is clocked from an independent low-speed internal oscillator. In the down counter, the 8-bit prescaler, the reload register and the window registers are implemented in the VDD domain, which allows the peripheral to be operational in all stop modes as well as in the standby low power mode. The objective for this session is to learn how to set up and refresh the independent window watchdog. After configuring the peripherals in the STM32QBmx, we will make use of an LED to observe the behavior of the independent window watchdog. The hands-on is going to be very simple. A part of the peripheral initialization, we are going to implement 200 milliseconds of delay and a right-pin function which will drive the LED. If we do not refresh the independent watchdog, the program will be constantly restarting, leaving the perception that the LED is tackling. In the other case, if the watchdog would be refreshed, the LED would just be simply turned on. Let's start our STM32QBmx to initialize the peripherals. When the STM32QBmx is loaded, we are going to start a new project. We are going to type our part number STM32L476VG and we will start a new project. As a first step, we will configure the pinpe812put mode and we will also enable the independent window watchdog. On the clock configuration tab, the independent window watchdog will become available and as you can see, our program is being clocked by the MSI. Let's now configure the independent watchdog with a 12-bit down counter set to its maximum and not making use of the window feature if we set the pre-scaler to 4 and using the 32kHz LSI as a clock source, 496 ticks will take about 512ms and this is the timeout value for our watchdog. As we just finished to configure our peripherals, now we just need to save the project and generate our code. As always, we are going to use system workbench for STM32 to program our code. After the system workbench for STM32 loads, we are going to source to our main file and here we should see our peripherals initialized. We are going to the independent window watchdog configuration and the parameters should match what we input in the STM32QBmx. We will proceed to add our delay function and we are going to configure it with 200ms. After this, we are just going to drive the LED and to do so, we are going to use the HAL GPIO write pin function. The input parameters are the pin port, the pin itself and the state that you would like to drive. With the program all written, now we are just going to build our project and debug it. After launching our program and if we would look at our board, we will see our LED tagging which means that the independent window watchdog is causing the program to restart and for as user it seems that the LED is tagging. Now we will terminate the debug session and we will add the independent window watchdog refresh function. Here for this function will be the pointer to the handler of the independent window watchdog. Build once again our project and we will launch it. As you can expect, since now we included the refresh function, the LED will be constantly on. Thank you for watching this session.