1564 views|0 replies

2015

Posts

0

Resources
The OP
 

Application of independent watchdog IWDG in STM32F4 series MCU [Copy link]

To improve the reliability of the system, the STM32F4 series MCU has an independent watchdog (IWDG) and a window watchdog (WWDG). Today's experiment is about the independent watchdog. The clock source used by the independent watchdog is the internal low-speed oscillator LSI. Because LSE may not be connected, HSE may be broken, and HSI may be disconnected when HSE is running... For many reasons, LSI is the best independent watchdog clock. Application of independent watchdog IWDG of STM32F4 series MCU [Main features of IWDG] 1. Independent down counter2. Internal RC oscillator as clock source3. When the counter value is reduced to 0, reset MCU [IWDG configuration steps] 1. Set the KR register to prepare for writing data to PR and RLR. Write 0x5555 to KR to enable writing PR and RLR 2. Write the pre-scaling value and reload value. The pre-scaling is to divide the LSI, and the reload value is the starting value of each re-counting. 3. Write 0xAAAA to KR to enable counting. 4. Write 0x5555 to KR to restart counting. Otherwise, it will reset when the count reaches 0. [Code Implementation] This experiment relies on the previous LED experiment. The phenomenon of the first step of the experiment is that the LED flashes repeatedly. The phenomenon of the second step is that the LED lights up and then goes out. Part one: int main() { NVIC_Config(); LED_Init(); LEDOn(LED1); delay_ms(500); LEDOff(LED1); IWDG_WriteAccessCmd (IWDG_WriteAccess_Enable);//Enable writing PR and RLR IWDG_SetPrescaler (IWDG_Prescaler_128); //Write PR prescaler value IWDG_SetReload(100); //Write RLR IWDG_Enable(); //KR writes 0xCCCC while(1) { IWDG_ReloadCounter(); //KR writes 0x5555 to restart counting and not reset } } In this experiment, we can see that the LED lights up for a moment and then remains dark, which means the MCU has not been reset. In the second part, we do not reinstall the RLR counter and see if the mcu cannot be reset int main() { NVIC_Config(); LED_Init(); LEDOn(LED1); delay_ms(500); LEDOff(LED1); IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); //Enable writing PR and RLR IWDG_SetPrescaler(IWDG_Prescaler_32); //Write PR prescaler value IWDG_SetReload(100); //Write RLR IWDG_Enable(); //KR write 0xCCCC while(1) { //Waiting for the mcu to be reset by IWDG } This time you can see the LED flashing.

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list