STM32 Study Notes---IWDG Independent Watchdog Experiment

Publisher:leader5Latest update time:2016-02-25 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
After doing the WWDG window watchdog experiment, we continued with the 9th experiment - IWDG independent watchdog experiment. In this experiment, we set the window watchdog IWDG interrupt time to regularly check whether there is an error. In the SysTick_Handler interrupt function, a running light is added to test whether the IDWG watchdog program is running. The feasibility of the program is verified by flashing PD6-LED2. The programming project is roughly the same as the USART experiment process. First, turn on the system clock, then the GPIO port clock, then the multiplexing function clock AFIO, and then the clock used by each module. After that, enter the initialization, setting, and writing of each module. For interrupts, fill in the interrupt trigger processing function of a certain module in the interrupt function. The important thing is to turn on the module declaration in the CONFG.H function. That's about it.

The following are the main parts of the IWDG function:

//IWDG window watchdog setting initialization
void IWDG_Config(void)

 //Independent watchdog initialization
  IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); //Start register reading and writing

  IWDG_SetPrescaler(IWDG_Prescaler_32); //40K clock divided by 32

  IWDG_SetReload(349);                 //Counter value

  IWDG_ReloadCounter();             //Restart counter

  IWDG_Enable();                       //Start watchdog
}
***************************************************************

Precautions:

i. If you have a dog, you can ignore it normally, but don’t forget to feed it, otherwise it will die without knowing how!

ii. The initialization program must be called after systic is initialized.

iii. The independent watchdog needs to be fed by the systic interrupt, but systic can't just do this, so I wrote the following code, which will not affect other applications of systic. Other systic cycle codes can also be used for reference:

Step 1: Define variables in stm32f10x_it.c

int Tic_IWDG;           //Frequency determination variable of dog feeding cycle program

Step 2: Change the dog feeding code in SysTickHandler to the following:

Tic_IWDG++;          //Variable increment

if(Tic_IWDG>=100)    //feed the dog every 100 systic cycles

 IWDG_ReloadCounter(); //Restart counter (feed the dog)

  Tic_IWDG=0;       // variable clear

}

The complete code is

void SysTick_Handler(void)
{
 Tic_Val++;           //Precise delay variable increment

 Tic_IWDG++;          //Independent watchdog variable increment

 if(Tic_IWDG>=100)    //feed the dog every 100 systic cycles

  
   IWDG_ReloadCounter(); //Restart counter (feed the dog)
   Tic_IWDG=0;       //Clear the variable

 switch(IWDGFLAG)
 {
 case 0:
  GPIO_SetBits(GPIOD, GPIO_Pin_6);
    break;
 case 1:
  GPIO_ResetBits(GPIOD, GPIO_Pin_6);
    break;
 default:
    break;
 }
 IWDGFLAG=!IWDGFLAG;

 }
}
The following is the result of the IWDG function:






 

Keywords:STM32 Reference address:STM32 Study Notes---IWDG Independent Watchdog Experiment

Previous article:STM32 clock system
Next article:STM32 RTC configuration and oscillation issues

Recommended ReadingLatest update time:2024-11-16 14:35

STM32 timer study notes
TIMx is composed of a 16-bit counter, a prescaler, and an automatic load register. Counter: 16 bits (0-65535) Prescaler 16 bits (register controlled counter) When the pre-scaling frequency is 1, the counter increases by 1 for each time pulse, and when the pre-scaling frequency is 2, the counter increases by 1 for ever
[Microcontroller]
STM32 uses systick to achieve precise delay
SYSTICK register initialization void SysTick_Configuration(void) {     if (SysTick_Config(SystemCoreClock / 100))          {         while (1);   }     NVIC_SetPriority(SysTick_IRQn, 0x0);                } SysTick_Config default clock is SysTick_CLKSource_HCLK, so using SysTick_CLKSourceConfig() to select the system c
[Microcontroller]
STM32 functional pin remapping and multiplexing functions
Stm32 pin general application: ANALOGINPUT_AIN -- Apply ADC analog input, or save power in low power mode. Floating input_IN_FLOATING——Can be used for KEY recognition, RX1 Open drain output_Out_OD——applied to I2C bus; (STM32 open drain output can only output 0 if no external pull-up resistor is connected) Many
[Microcontroller]
Understanding of SysTick of stm32
1. Introduction to SysTick (the above information comes from the CM3 Chinese reference manual)     The SysTick timer is bundled in the NVIC and is used to generate the SYSTICK exception (exception number: 15). In the past, most operating systems required a hardware timer to generate the tick interrupts required by the
[Microcontroller]
STM32 data transmission peripherals: learning of three common interfaces: USART, I2C, and SPI
1. USART serial interface Serial interfaces are divided into asynchronous serial interfaces and synchronous serial interfaces. Asynchronous serial interfaces are collectively referred to as universal asynchronous receiver and transmitter interfaces UART, and UART with synchronization function (including clock signal
[Microcontroller]
STM32 data transmission peripherals: learning of three common interfaces: USART, I2C, and SPI
STM32 serial port register library function configuration method
1. References       "STM32F1 Development Guide - Library Function Version" - 5.3 usart serial port folder introduction                                     - Chapter 9 Serial Port Experiment       "STM32 Chinese Reference Manual V10" - Chapter 25 Universal Synchronous Asynchronous Receiver Transmitter (USART) 2.
[Microcontroller]
STM32 serial port register library function configuration method
STM32 study notes on the use of independent watchdog (IWDG)
     Before using any STM32 module, it must be initialized. The first step is to initialize the peripheral clock. You can simply read the system clock chapter about the peripheral clock and the data sheet as follows: The watchdog is driven by an independent internal 40M clock, so we do not need to initialize the cl
[Microcontroller]
STM32 study notes on the use of independent watchdog (IWDG)
STM32's I2C hardware bug caused a murder
There is a BUG in the function below, that is, SR2 cannot be polled using WHILE, but should be read directly. As shown in the following code segment, Therefore, what I say here is a BUG of STM32 is actually an error in my code:     I2C2- DR = inerAddress ;     while( (I2C2- SR1&Q_I2C_SR1_BIT_BTF)==0 );     I2C2- SR2;
[Microcontroller]
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号