STM32看门狗配置说明

STM32看门狗配置说明系统时钟:TheWWDGclockisprescaledfromtheAPBclockandhasaconfigurabletime-windowthatcanbeprogrammedtodetectabnormallylateorearlyapplicationbehavior./**@defgroupWWDG_PrescalerWWDGPrescaler*@{*/#defineWWDG_PRESCALER_10x

大家好,又见面了,我是你们的朋友全栈君。

系统时钟:
在这里插入图片描述

The WWDG clock is prescaled from the APB clock and has a configurable time-window that
can be programmed to detect abnormally late or early application behavior.

/** @defgroup WWDG_Prescaler WWDG Prescaler * @{ */
#define WWDG_PRESCALER_1 0x00000000u /*!< WWDG counter clock = (PCLK1/4096)/1 */
#define WWDG_PRESCALER_2 WWDG_CFR_WDGTB_0 /*!< WWDG counter clock = (PCLK1/4096)/2 */
#define WWDG_PRESCALER_4 WWDG_CFR_WDGTB_1 /*!< WWDG counter clock = (PCLK1/4096)/4 */
#define WWDG_PRESCALER_8 (WWDG_CFR_WDGTB_1 | WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/8 */

寄存器配置

  hwwdg.Instance = WWDG;
  hwwdg.Init.Prescaler = WWDG_PRESCALER_1;
  hwwdg.Init.Window = 240;
  hwwdg.Init.Counter = 240;
  hwwdg.Init.EWIMode = WWDG_EWI_DISABLE;
  if (HAL_WWDG_Init(&hwwdg) != HAL_OK)
  { 
   
    Error_Handler();
  }

理论计算时间(1分频)
T = 240 ∗ 4096 8000000 ∗ 1000 = 122.88 m s T = \frac{240*4096}{8000000} *1000= 122.88ms T=800000024040961000=122.88ms

2分频时间为: 2*122.88 = 245.76ms

喂狗:

/** * @brief Refresh the WWDG. * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains * the configuration information for the specified WWDG module. * @retval HAL status */
HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg)
{ 
   
  /* Write to WWDG CR the WWDG Counter value to refresh with */
  WRITE_REG(hwwdg->Instance->CR, (hwwdg->Init.Counter));

  /* Return function status */
  return HAL_OK;
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/135639.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号