微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > stm32F4系列MCU,窗口看门狗 WWDG中的bug

stm32F4系列MCU,窗口看门狗 WWDG中的bug

时间:11-19 来源:互联网 点击:
stm32F4系列MCU窗口看门狗 WWDG中的bug

1. 如果使能预喂狗中断,那么必须满足如下两点
(1)在开启wwdg中断之前,需要先将 SR 寄存器中的EWI标志位清零,否则会看门狗会不断复位
(2)在wwdg_irq里加上一小段延时,否则看门狗会不断复位
2. 如果系统里还有其他中断,比如按键,在按键中断中设置一个变量,这个变量在wwdg_isr中读取,来决定是否停止喂狗
这样按下按键以后,系统直接就飞了。
这里给出一个测试代码。 如下所示。

/* @file    USART/USART_Printf/main.c * @author  MCD Application Team* @version V1.0.1* @date    13-April-2012* @brief   Main program body* @attention** 

COPYRIGHT 2012 STMicroelectronics

** Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");* You may not use this file except in compliance with the License.* You may obtain a copy of the License at:** http://www.st.com/software_license_agreement_liberty_v2** Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.**//* Includes ------------------------------------------------------------------*/#include "stm32f4xx.h"#include "stm324xg_eval.h"#include / @addtogroup STM32F4xx_StdPeriph_Examples* @{*// @addtogroup USART_Printf* @{*/ /* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*//* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*/USART_InitTypeDef USART_InitStructure;/* Private function prototypes -----------------------------------------------*/#ifdef __GNUC__/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printfset to Yes) calls __io_putchar() */#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)#else#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)#endif /* __GNUC__ *//* Private functions ---------------------------------------------------------*/void delay(int t);void wwdg_nvic_config(void);void key_init(void);/* @brief Main program* @param None* @retval None*/int main(void){int i = 0;RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);/*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startupfile (startup_stm32f4xx.s) before to branch to application main.To reconfigure the default setting of SystemInit() function, refer tosystem_stm32f4xx.c file*/ /* USARTx configured as follow:- BaudRate = 115200 baud - Word Length = 8 Bits- One Stop Bit- No parity- Hardware flow control disabled (RTS and CTS signals)- Receive and transmit enabled*/USART_InitStructure.USART_BaudRate = 115200;USART_InitStructure.USART_WordLength = USART_WordLength_8b;USART_InitStructure.USART_StopBits = USART_StopBits_1;USART_InitStructure.USART_Parity = USART_Parity_No;USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;STM_EVAL_COMInit(COM1, &USART_InitStructure);/* Output a message on Hyperterminal using printf function */printf("\n\rUSART Printf Example\n\r");/* key configuration */key_init();/* WWDG configuration *//* Enable WWDG clock */RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE);/* WWDG clock counter = (PCLK1 (42MHz)/4096)/8 = 1281

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top