【iCore4 雙核心板_ARM】例程七:WWDG看門狗實驗——復位ARM

XiaomaGee發表於2017-08-16

實驗原理:

  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連結:

相關文章