The block diagram of the independent watchdog is as follows
We can see that the clock of the independent watchdog comes from the low-speed oscillator inside LSI, and reaches the watchdog peripheral unit after being divided by two, and then reaches the counter after a seven-bit pre-division. This seven-bit division is controlled by PR. The watchdog uses an eight-bit down-counting counter to count. When the count reaches 0, a watchdog reset signal is issued. At the same time, there is an RLR that can store the initialization value of the watchdog. However, when operating KR, the watchdog counter reloads the data of RLR to achieve the purpose of feeding the dog.
Therefore, the processing of the watchdog should be divided into the following steps
1. Disable the watchdog
2. Start the LSI system low speed clock
3. Set the clock division factor
4. Set the watchdog reload value
5. Feed the dog before resetting and restart the counting
The relevant registers are as follows
See the following code for usage
#ifndef __IWDG_H_ #define __IWDG_H_ #include "stm8s.h" void IWDGInit(void); //Default count time is one second void IWDGFeed(void); #endif
#include "iwdg.h" void IWDGInit(void) //Default count time is one minute { //First turn on the LSI clock CLK->ICKR = (1<<3); while((CLK->ICKR&(1<<4)) == 0); //Wait for the clock to stabilize IWDG->KR = 0x55; //Write unlock IWDG->PR = 0x06; //Division 64K /256 = 250 IWDG->RLR = 250; //Count value 250 1 reset IWDG->KR = 0xaa; //Lock and refresh the divider IWDG->KR = 0xcc; //Start independent watchdog } void IWDGFeed(void) { IWDG->KR = 0xaa; //Lock and refresh the divider }
Window watchdog is another mode. The chip defines a lower limit, which generates a reset when it is lower than 0x40, and also defines an upper limit. When it is higher than the upper limit, the watchdog also generates a reset.
The clock of the window watchdog comes from the CPU clock, and the frequency division number is 12288. The process of using the watchdog is as follows
1Set window value
2Set the current count value
3 Start the watchdog
Once the window watchdog is started, it cannot be turned off unless a reset occurs and the system automatically turns off the window watchdog. For specific usage, see the code.
#ifndef __WWDG_H_ #define __WWDG_H_ #include "stm8s.h" void WWDGInit(void); void WWDGFeed(void); #endif
#include "wwdg.h" void WWDGInit(void) { if((WWDG->CR&0x80) == 1) { return; } else { WWDG->WR = 0x60; WWDG->CR = 0xff; } } void WWDGFeed(void) { u8 windows = WWDG->WR ; if((WWDG->CR&0x7f)>=windows) return; else WWDG->CR = 0x7f; }
Previous article:STM8S independent watchdog configuration and use
Next article:Design of Industrial Watt-hour Meter with CAN Bus Based on ADE7755
Recommended ReadingLatest update time:2024-11-23 16:51
- Popular Resources
- Popular amplifiers
- STM8 C language programming (1) - basic program and startup code analysis
- Description of the BLDC back-EMF sampling method based on the STM8 official library
- STM32 MCU project example: Smart watch design based on TouchGFX (8) Associating the underlying driver with the UI
- uCOS-III Kernel Implementation and Application Development Practical Guide - Based on STM32 (Wildfire)
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Share a DSP28335 SVPWM program source code for reference
- Detailed explanation of the concepts of potential, voltage and level
- Tom filters sensitive Skype messages at the request of the Chinese government
- Energy saving: the driving force for continued growth in power management
- Libero IDE 7.2 increases flexibility for Actel FPGA-based designs
- Switching Power Supply Interest Group Task 03
- Fixed-point and floating-point numbers in C2000
- Introduction to Gizwits Mini Programs: WebSocket Web Page Control
- EEWORLD University ---- Miz702 zynq video beginner tutorial (Milinke)
- msp430f5529 interrupt notes