【iCore4 双核心板_ARM】例程七:WWDG看门狗实验——复位ARM

实验原理:

  STM32内部包含窗口看门狗,通过看门狗可以监控程序运行,程序运行错误时,未在

规定时间喂狗(提前或超时),自动复位ARM,本实验通过按键按下,停止喂狗,从而产

生复位。

核心代码:

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */
    HAL_Delay(300);
  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_WWDG_Init();

  /* USER CODE BEGIN 2 */
    LED_RED_ON;

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
        while(ARM_KEY_STATE == KEY_DOWN);
        HAL_Delay(30);                                        //30msι¹·Ò»´Î
      HAL_WWDG_Refresh(&hwwdg);                    //ι¹·

  }
  /* USER CODE END 3 */

}

源代码下载链接:

链接:http://pan.baidu.com/s/1cizRjg 密码:2s6f

iCore4链接:

posted @ 2017-08-16 11:19  XiaomaGee  阅读(489)  评论(0编辑  收藏  举报