STM32F0xx_watchdog (independent + window) configuration detailed process

Publisher:WhisperingGlowLatest update time:2017-09-15 Source: eefocusKeywords:STM32F0xx Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.


Keywords:STM32F0xx Reference address:STM32F0xx_watchdog (independent + window) configuration detailed process

Previous article:UCOS2_STM32F1 transplantation detailed process (Part 2)
Next article:STM32F0xx_FLASH programming (on-chip) configuration detailed process

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号