I. Overview
I think people who work on microcontrollers or embedded systems are not unfamiliar with watchdogs. Today I will summarize the functions of the STM32F0 watchdog. There are two types of watchdogs for F0: independent and window watchdogs.
Today we provide two watchdog software engineering examples for everyone to download.
The two watchdogs have their own characteristics and are used in different occasions. The following will briefly summarize the functions of independent and window watchdogs respectively.
Ⅱ. Download
The "software engineering" provided in the article has been tested many times on the hardware board and uploaded to the 360 cloud disk only after it is guaranteed to be problem-free. Please feel free to download and test it. If there is any problem, please check whether there is any problem with your board.
ST standard peripheral libraries, reference manuals, data sheets, etc. can all be downloaded from the ST official website , or you can download them from my 360 cloud disk. There are multiple versions of the reference manual for the F0 series chips (for different F0 chips), but there is a universal version, "STM32F0x128 Reference Manual V8 (English) 2015-07". It is recommended to refer to this manual, which will be convenient for you to understand if you change to a different chip model in the future.
Today's software engineering download address (360 cloud disk):
IWDG Independent Watchdog:
https://yunpan.cn/cRfa8Qhi9g48Y Access password 2c3e
WWDG Window Watchdog:
https://yunpan.cn/cRfa5DvT9syUm Access password 7bf1
The information of STM32F0xx can be downloaded from my 360 cloud disk:
https://yunpan.cn/cS2PVuHn6X2Bj Access password 8c37
III. Preparation
For watchdog programming, it is recommended that you prepare the reference manual and data sheet of F0 for easy reference of relevant knowledge. If you don’t have it, please go to the ST official website or download it from my 360 cloud disk.
The software project summarized today is modified based on the "Detailed Process of TIM Basic Delay Configuration", so you need to download the software project and prepare it. I always provide the organized software project for everyone to download, but if you are a learner, it is recommended that you operate it step by step by yourself.
IV. Watchdog Principle
①IWDG independent watchdog
The independent watchdog is provided with counting clock by the internal low-speed clock LSI, 8-bit frequency division, 12-bit counting, and needs to be fed regularly (reload value ReloadCounter). If the count value is reduced to 0 and the value has not been reloaded, it will respond to the reset event.
②WWDG window watchdog
The window watchdog is provided with a counting clock by APB1 (RCC_APB1Periph_WWDG), 2-bit frequency division, 7-bit counting, and needs to be fed regularly (count value updated). If the count value is reduced to 0x40 and the count value has not been updated, it will respond to a reset event.
V. Code Description
Today we provide two watchdog software projects. Let’s summarize them respectively and mainly explain the configuration function interface.
①IWDG independent watchdog
This function is located above the main.c file;
Please refer to the above structure diagram and the function source code to calculate the overloaded value. It can be seen from the function that it only takes 0.5s.
running result:
The maximum time for feeding the dog is 500ms (theoretical value), but there is an error in the internal low-speed clock LSI. It is recommended to modify the test time: less than 450, greater than 550;
Less than 450ms: feeding the dog normally, the serial port prints "Running..." at intervals and LED changes;
Greater than 550ms: Dog feeding timeout, system reset, serial port prints "System Reset..."
②WWDG window watchdog
This function is located above the main.c file;
The clock here is different from the clock of IWDG above. Combined with the block diagram, it can be seen that the count value can also be calculated after frequency division.
running result:
The maximum time for feeding the dog is 43ms (theoretical value), but serial port printing requires one or two milliseconds. It is recommended to modify the test time: less than 41, greater than 43;
Less than 41ms: feeding the dog normally, the serial port prints "Running..." LED changes at intervals;
Greater than 43ms: Dog feeding timeout, system reset, serial port prints "System Reset..."
③Summarize the difference between the two
1) IWDG uses the internal low-speed clock LSI, and WWDG uses the system clock APB1ENR
2) IWDG has no interruption, WWDG has an interruption
3) IWDG is 12-bit decrement. WWDG is 7-bit decrement
4) IWDG has only a lower limit, while WWDG has a lower limit and an upper limit
5) IWDG is most suitable for applications that require the watchdog to work completely independently outside the main program and have low requirements for time accuracy. WWDG is most suitable for applications that require the watchdog to work in a precise timing window.
Watchdog is widely used in products that work for a long time. Its function is very simple, to prevent the system from freezing. The function of watchdog can also be used for timing counting, etc.
VI. Description
Maybe your hardware chip is not the chip provided in the project, but the chip software compatibility of STM32F0 is very good, and it can be applied to many other types of F0 chips, even F2, F4 and other chips (please refer to the manual for details, or test it yourself).
The software project provided in this article is built based on the ST standard peripheral library, rather than using STM32CubeMX to build the project. I personally think that using ST's standard peripheral library is suitable for learners, and the STM32CubeMX project structure is complex, which is probably a headache for learners, especially beginners.
Today's project is modified based on the project "STM32F0xx_TIM basic delay configuration detailed process". The above example summary is for reference only. If there are any mistakes, please forgive me.
Previous article:UCOS2_STM32F1 transplantation detailed process (Part 2)
Next article:STM32F0xx_FLASH programming (on-chip) configuration detailed process
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- SHT31 Review + Unboxing Test
- How to obtain high-frequency equivalent models of devices such as varistors and TVS transient diodes
- MicroPython uses the new neopixel driver
- Review Weekly Report 20220509: Saifang RISC-V Linux Starlight Board is coming, how is the Xianji 800MHz HPM6750 tested?
- How to set default rules for Altium drawing?
- Matlab and Modelsim co-simulation error
- Recruitment of assistant engineers
- ST NUCLEO-G071RB evaluation application - Come and experience the new generation of entry-level 32-bit STM32, giving you the best cost-effective experience
- Security innovation, a new verification method. Download Fujitsu's "Spectrum Verification Solution" white paper and get a gift!
- Which forum member has a deeper understanding of MOS tubes? I usually overlook some parameters when reading the specification, and I want to understand them all today. Know...