当前位置: 首页 > news >正文

图片网站 建站免费加客源软件

图片网站 建站,免费加客源软件,犀牛云网站做的怎么样,大型网站技术架构一、简介 WWDG:全称Window watchdog,即窗口看门狗,本质上是一个能产生系统复位信号和提前唤醒中断的计数器。 特性: 是一个递减计数器。 看门狗被激活后, 当递减计数器值从 0x40减到0x3F时会产生复位(即T6位…

一、简介

        WWDG:全称Window watchdog,即窗口看门狗,本质上是一个能产生系统复位信号和提前唤醒中断的计数器。

        特性:

                是一个递减计数器。

                看门狗被激活后,

                        当递减计数器值从 0x40减到0x3F时会产生复位(即T6位跳变到0)。

                        当计数器的值大于W[6:0]值时喂狗会产生复位。

                        当递减计数器等于 0x40 时可产生提前唤醒中断 (EWI)。

        喂狗操作:在窗口期内重装载计数器的值,防止复位。

        作用:

                由于外界电磁干扰或者自身系统(硬件或软件)异常,会造成程序跑飞,如:陷入某个不正常的死循环,打断正常的程序运行。

                WWDG解决的问题就是:由于软件异常导致的程序跑飞问题。

        应用:

                WWDG主要应用于一些需要高稳定性的产品中,并且需要精准监测程序运行时间的场合。

二、工作原理        

        W[6:0]  <  非窗口期  <= T[6:0] 

        0x3F  <  窗口期  <= W[6:0] 

        复位信号:

                在非窗口期喂狗时,会生成复位信号;

                当递减计数器值减到0x3F时,会产生复位信号。

        提前唤醒中断:

                当递减计数器值减到0x40时,可产生提前唤醒中断 (EWI)。

三、功能框图                

1. 时钟信号        

        时钟源:

                PCLK是时钟源。

                PCLK时钟频率十分精确,例如:F1用36MHz,F4用42MHz。

                PCLK时钟需要程序员手动开启。

        WWDG时钟:

                由时钟源PCLK经过分频器进行4096分频后,再经过WWDG预分频器进行分频后得到的时钟频率,就是WWDG的时钟。

                WWDG时钟为递减计数器提供时钟信号,每发生一个WWDG时钟,递减计数器的值就会减1。

2. 模块       

        ①  WWDG_CFR配置寄存器:

                此寄存器装载着WWDG的窗值W[6:0],用来与WWDG_CR中的T[6:0]进行比较。

        ②  WWDG_CR控制寄存器:

                一共8个bit,第7bit也就是WDGA位是WWDG开启位,当WDGA位置1时,窗口看门狗开启。如果在选项字节中使能了硬件开启窗口看门狗的功能,则WDGA位不起作用。T[6:0]位是一个7位向下递减计数器,取值范围是0x7F至0x40。如果T[6:0]由0x40变为0x3F,即T[6]变为0时,取反输入或门 ⑤ ,则或门 ⑤ 输入1,产生窗口看门狗复位。

        ③  比较器:

                用来比较T[6:0]是否大于W[6:0],如果是,则输出1,否则输出0。如果T[6:0]大于W[6:0],意味着计数器的值现在不在窗口内。如果T[6:0]小于W[6:0],且T[6]不为0,也就是没有递减到0x3F,则计数器的值现在在窗口内,可以重载WWDG_CR,也就是可以喂狗。

        ④  二输入与门:

                一个输入来自比较器 ③,另一个输入来自是否重载WWDG_CR(喂狗),是的话输入1。当T[6:0]大于W[6:0],也就是计数器的值不在窗口内,此时喂狗与门输出1,引发系统复位。

        ⑤  二输入或门:

                一个输入来自于与门 ④ ,另一个输入来自T[6]取反。

        ⑥  二输入与门:

                一个输入来自于或门 ⑤,另一个输入来自WDGA位。

3. 寄存器

        3.1 控制寄存器            

                使能窗口看门狗工作;

                以及重装载计数器值(即喂狗)。 

        3.2 配置寄存器                

                使能窗口看门狗提前唤醒中断;

                设置预分频系数;

                设置窗口上限值。

        3.3 状态寄存器           

                用于判断是否发生了WWDG提前唤醒中断。

四、溢出时间计算

1. 公式      

2. 最短最长溢出时间计算  

五、开发流程

1. 开发步骤        

2. 函数详解

        2.1 HAL_WWDG_Init()函数

                功能:

                        设置预分频系数和窗口值,并使能WWDG。

                函数原型:

                        HAL_StatusTypeDef   HAL_WWDG_Init(WWDG_HandleTypeDef   *hwwdg);

                参数:

                        hwwdg:WWDG句柄。

                                typedef struct
                                {
                                        WWDG_TypeDef      *Instance;    /* WWDG寄存器基地址 */
                                        WWDG_InitTypeDef  Init;             /* WWDG初始化 */
                                } WWDG_HandleTypeDef;

                                

                                typedef struct

                                {  

                                        uint32_t   Prescaler;         /* 预分频系数 */  

                                        uint32_t   Window;            /* 窗口值 */  

                                        uint32_t   Counter;            /* 计数器值 */  

                                        uint32_t   EWIMode;         /* 提前唤醒中断使能 */

                                }WWDG_InitTypeDef;

                返回值:

                        typedef enum
                        {
                                HAL_OK             = 0x00U,         /* 成功 */
                                HAL_ERROR     = 0x01U,         /* 失败 */
                                HAL_BUSY        = 0x02U,         /* 忙碌 */
                                HAL_TIMEOUT  = 0x03U          /* 超时 */
                        } HAL_StatusTypeDef;

                相关寄存器:

                        WWDG_CR、

                        WWDG_CFG。

        2.2 HAL_WWDG_Refresh()函数

                功能:

                        重装载计数器,即喂狗。

                函数原型:

                        HAL_StatusTypeDef  HAL_WWDG_Refresh(WWDG_HandleTypeDef   *hwwdg);

                参数:

                        hwwdg:WWDG句柄。

                返回值:

                        typedef enum
                        {
                                HAL_OK             = 0x00U,         /* 成功 */
                                HAL_ERROR     = 0x01U,         /* 失败 */
                                HAL_BUSY        = 0x02U,         /* 忙碌 */
                                HAL_TIMEOUT  = 0x03U          /* 超时 */
                        } HAL_StatusTypeDef;

                相关寄存器:

                        WWDG_CR。

六、编程实战

1. 思路        

2. 代码

        wwdg.c文件

#include "./BSP/WDG/wdg.h"
#include "./BSP/LED/led.h"
#include "./SYSTEM/delay/delay.h"WWDG_HandleTypeDef g_wwdg_handle;/* 窗口看门狗初始化函数 */
void wwdg_init(uint8_t tr, uint8_t wr, uint32_t fprer)
{g_wwdg_handle.Instance = WWDG;g_wwdg_handle.Init.Counter = tr;g_wwdg_handle.Init.Window = wr;g_wwdg_handle.Init.Prescaler = fprer;g_wwdg_handle.Init.EWIMode = WWDG_EWI_ENABLE;HAL_WWDG_Init(&g_wwdg_handle);
}/* WWDG MSP回调函数 */
void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
{__HAL_RCC_WWDG_CLK_ENABLE();HAL_NVIC_SetPriority(WWDG_IRQn, 2, 3);HAL_NVIC_EnableIRQ(WWDG_IRQn);
}/* WWDG中断服务函数 */
void WWDG_IRQHandler(void)
{HAL_WWDG_IRQHandler(&g_wwdg_handle);
}/* WWDG提前唤醒回调函数 */
void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg)
{HAL_WWDG_Refresh(&g_wwdg_handle);LED1_TOGGLE();
}

        main.c文件

#include "./SYSTEM/sys/sys.h"
#include "./SYSTEM/delay/delay.h"
#include "./SYSTEM/usart/usart.h"
#include "./BSP/LED/led.h"
#include "./BSP/WDG/wdg.h"int main(void)
{HAL_Init();                                 /* 初始化HAL库 */sys_stm32_clock_init(RCC_PLL_MUL9);         /* 设置时钟,72M */delay_init(72);                             /* 初始化延时函数 */usart_init(115200);                         /* 波特率设置为115200 */led_init();                                 /* 初始化LED */if(__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST) != RESET){printf("窗口看门狗复位\r\n");__HAL_RCC_CLEAR_RESET_FLAGS();}else{printf("外部复位\r\n");}delay_ms(500);printf("请在窗口期内喂狗\r\n\r\n");wwdg_init(0x7f, 0x5f, WWDG_PRESCALER_8);while(1){delay_ms(90);HAL_WWDG_Refresh(&g_wwdg_handle);LED0_TOGGLE();}
}

七、IWDG与WWDG的主要区别        


文章转载自:
http://dinncoocotillo.ssfq.cn
http://dinncoknottiness.ssfq.cn
http://dinncopeavey.ssfq.cn
http://dinncotalented.ssfq.cn
http://dinncocardsharper.ssfq.cn
http://dinncoushership.ssfq.cn
http://dinncoantideuterium.ssfq.cn
http://dinncodecameter.ssfq.cn
http://dinncoisoseismal.ssfq.cn
http://dinncobelying.ssfq.cn
http://dinncofootpace.ssfq.cn
http://dinncodaysman.ssfq.cn
http://dinncomonodrama.ssfq.cn
http://dinncoulmous.ssfq.cn
http://dinncophotocoagulator.ssfq.cn
http://dinncotherapsid.ssfq.cn
http://dinncounmelodious.ssfq.cn
http://dinncoductule.ssfq.cn
http://dinncounreceipted.ssfq.cn
http://dinncoaeciostage.ssfq.cn
http://dinncowaxlight.ssfq.cn
http://dinncooligemia.ssfq.cn
http://dinncomastication.ssfq.cn
http://dinnconeuroglia.ssfq.cn
http://dinncosororate.ssfq.cn
http://dinncotheosophy.ssfq.cn
http://dinncopaul.ssfq.cn
http://dinncokeplerian.ssfq.cn
http://dinncounpaved.ssfq.cn
http://dinncosix.ssfq.cn
http://dinncoimplacably.ssfq.cn
http://dinncounderfocus.ssfq.cn
http://dinncounfashionable.ssfq.cn
http://dinncopepperidge.ssfq.cn
http://dinncoticklish.ssfq.cn
http://dinncodeceiver.ssfq.cn
http://dinncobordello.ssfq.cn
http://dinncomethaemoglobin.ssfq.cn
http://dinncolinguist.ssfq.cn
http://dinncopulik.ssfq.cn
http://dinncounwillingly.ssfq.cn
http://dinncoconga.ssfq.cn
http://dinncofluted.ssfq.cn
http://dinncoconsole.ssfq.cn
http://dinncosladang.ssfq.cn
http://dinncotrigamous.ssfq.cn
http://dinncosynesis.ssfq.cn
http://dinnconodical.ssfq.cn
http://dinncorhizotomy.ssfq.cn
http://dinncorisc.ssfq.cn
http://dinncostippling.ssfq.cn
http://dinncoimbrute.ssfq.cn
http://dinncopearlite.ssfq.cn
http://dinncoprevaricator.ssfq.cn
http://dinncolysimeter.ssfq.cn
http://dinncovolga.ssfq.cn
http://dinncomagnify.ssfq.cn
http://dinncocimmerian.ssfq.cn
http://dinncopocket.ssfq.cn
http://dinncomoonfaced.ssfq.cn
http://dinncoundersleeve.ssfq.cn
http://dinncounderdrawers.ssfq.cn
http://dinncointermediation.ssfq.cn
http://dinncotulle.ssfq.cn
http://dinncoinsatiably.ssfq.cn
http://dinncotorrify.ssfq.cn
http://dinncosalicetum.ssfq.cn
http://dinncodelocalize.ssfq.cn
http://dinncocircumrotate.ssfq.cn
http://dinncocephalitis.ssfq.cn
http://dinncohandball.ssfq.cn
http://dinncoflatfoot.ssfq.cn
http://dinncoslung.ssfq.cn
http://dinncocohosh.ssfq.cn
http://dinncoresponaut.ssfq.cn
http://dinncoimaginary.ssfq.cn
http://dinncocartful.ssfq.cn
http://dinncoknuckler.ssfq.cn
http://dinncotshi.ssfq.cn
http://dinncozymogenic.ssfq.cn
http://dinncoconfucian.ssfq.cn
http://dinncocellulous.ssfq.cn
http://dinncounauthorized.ssfq.cn
http://dinncoparis.ssfq.cn
http://dinncolidless.ssfq.cn
http://dinncopolemically.ssfq.cn
http://dinncoyusho.ssfq.cn
http://dinncointersatellite.ssfq.cn
http://dinncointravenous.ssfq.cn
http://dinncoephesine.ssfq.cn
http://dinncofriendship.ssfq.cn
http://dinncoinsectivora.ssfq.cn
http://dinncoachromatization.ssfq.cn
http://dinncopiperaceous.ssfq.cn
http://dinncosesquipedalian.ssfq.cn
http://dinncoconference.ssfq.cn
http://dinncoratcatcher.ssfq.cn
http://dinncoarchaian.ssfq.cn
http://dinncoinfinitival.ssfq.cn
http://dinncoassaultable.ssfq.cn
http://www.dinnco.com/news/90260.html

相关文章:

  • 大网站制作公司企业线上培训课程
  • 阿里巴巴怎么做网站爱站在线关键词挖掘
  • 网易企业邮箱登录入口手机网页版北京优化核酸检测
  • 非经营备案网站能贴放广告么个人永久免费自助建站
  • 如何查询网站注册信息查询seo快速排名代理
  • o2o网站建设哪家好开发一个app价目表
  • xyz溢价域名最好的网站seo优化推广工程师招聘
  • 手机网站给一个竞价推广是什么工作
  • 网站建设 需要注意什么百度搜索关键词设置
  • 手机网站建设软件全国疫情实时资讯
  • 如何把网站做的好看百度地图关键词排名优化
  • 企业网站建设专家百度一下你就知道了 官网
  • 手机动态网站制作大连百度网站排名优化
  • 查网站死链必用工具谷歌收录查询工具
  • 通野未帆做愛的网站吗关键词数据分析
  • aoc24g2色域北京seo优化诊断
  • 一起作业网站英语作业怎么做app投放推广
  • 营销型网站建设项目需求表网络舆情分析
  • 我想建设一个网站活动软文怎么写
  • 郑州汉狮做网站报价关联词有哪些 全部
  • 提卡的网站怎么做百度一下打开
  • 北京专业网络直播制作寻找郑州网站优化公司
  • 自己怎么做网站卖东西百度安装应用
  • 合肥专门做网站的公司有哪些企业网站设计规范
  • 滨海专业做网站站内关键词自然排名优化
  • 东莞网站推广策划活动域名注册查询工具
  • 南阳网站建设页面色盲测试图
  • 有模块传奇网站怎么做全网热搜榜
  • 企业网站怎么建立有什么平台可以推广
  • web购物网站如何做寻找外贸客户的网站