Independent watchdog and window watchdog of stm8

Publisher:JoyfulHarmonyLatest update time:2016-06-07 Source: eefocusKeywords:stm8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
STM8 has two hardware watchdogs, called independent watchdog and window watchdog.

The block diagram of the independent watchdog is as follows

Independent watchdog and window watchdog of stm8
 

 

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

Independent watchdog and window watchdog of stm8
Independent watchdog and window watchdog of stm8
Independent watchdog and window watchdog of stm8
 

 

 

 

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;
}


Keywords:stm8 Reference address:Independent watchdog and window watchdog of stm8

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

Design of vehicle head-up display based on STM8
With the increasing application of electronic technology and computer technology in automotive electronics, traditional mechanical instruments have been gradually replaced by electronic instruments. Electronic instruments have the advantages of small size and light weight, which can effectively save the limited spac
[Microcontroller]
Design of vehicle head-up display based on STM8
STM8 minimum development board/core board STM8S003F3P6 development and design effect
STM8S core board highlights:    This development board uses MicroUSB cable for power supply, which is compatible with smartphone data cables. Data cables are easy to obtain, rather than USB MINI cables for power supply. USB MINI cables are hard to find and have been gradually phased out. This is an important feature t
[Microcontroller]
STM8 minimum development board/core board STM8S003F3P6 development and design effect
STM8 timer TIM interrupt cannot enter
I use the IAR compiler. I played with STM8 last night and found that the style is quite similar to STM32, so I got the hang of it quickly. Today I played around with the TIM4 timer, but the interrupt just wouldn't work. I spent a lot of time looking up the interrupt number, service function, etc., and finally found th
[Microcontroller]
STM8 CPU register description
Introduction STM8S is a microcontroller based on an 8-bit framework structure. Its CPU core has 6 internal registers, through which data can be processed efficiently. The STM8S instruction set supports 80 basic 20 addressing modes, and the 6 internal registers of the CPU have addressable addresses. If you want to know
[Microcontroller]
STM8 CPU register description
Green hand_Programmable heater based on STM8
1. Question requirements:       A. Basic part (1) Can display the control temperature and actual working temperature; (2) The operating temperature can be set using the keyboard, and the temperature control error is required to be ±2°C; (3) When the temperature is lower than 30°C, the fan stops dissipating heat and t
[Microcontroller]
Green hand_Programmable heater based on STM8
STM8 MCU ADC analog watchdog Chinese data error
  When debugging the ADC analog watchdog function of the stm8 microcontroller, no matter how you set the values ​​of the ADC_HTR and ADC_LTR registers, the values ​​of these two registers are incorrect when you observe them during single-step debugging using the IAR software.   According to the Chinese manual, t
[Microcontroller]
STM8 MCU ADC analog watchdog Chinese data error
Displaying variable voltage on an LED strip using the STM8 Nucleo-64 development board
The UCLEO-8S208RB (based on STM8S208RBT6) and NUCLEO-8L152R8 (based on STM8L152R8T6) development boards can be used to evaluate the main features of all STM8S series and STM8L series microcontrollers. This application note briefly describes how to use the ADC, TIM and GPIO peripherals on the NUCLEO-8S208RB and NUCLE
[Microcontroller]
Displaying variable voltage on an LED strip using the STM8 Nucleo-64 development board
Latest Microcontroller Articles
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号