【iCore4 双核心板_ARM】例程六:IWDG看门狗实验——复位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 */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_IWDG_Init(); /* USER CODE BEGIN 2 */ /* 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_IWDG_Refresh(&hiwdg); LED_RED_ON; LED_GREEN_OFF; LED_BLUE_OFF; HAL_Delay(500); LED_RED_OFF; LED_GREEN_ON; LED_BLUE_OFF; HAL_Delay(500); LED_RED_OFF; LED_GREEN_OFF; LED_BLUE_ON; HAL_Delay(500); } /* USER CODE END 3 */ }
源代码下载链接:
链接:http://pan.baidu.com/s/1jI7lV74 密码:16ht
iCore4链接: