我用STM32CUBEMX生成项目,点亮LED灯,为什么在主循环里的500ms延时HAL_Delay(500),实际要近2S呢? 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(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); /* USER CODE BEGIN 2 */ LED_Init(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_GPIO_WritePin(GPIOF,GPIO_PIN_9,GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOF,GPIO_PIN_10,GPIO_PIN_SET); HAL_Delay(500); HAL_GPIO_WritePin(GPIOF,GPIO_PIN_9,GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOF,GPIO_PIN_10,GPIO_PIN_RESET); HAL_Delay(500); } /* USER CODE END 3 */ } |
我是中断优先级,把中断的调低一级,就能在中断里面用hal_delay()而不会异常了
æé ç½®çæ¶é