参考原子哥《STM32F429 FreeRTOS开发手册》教程,第四章FreeRTOS中断配置和临界段实验,我利用cubemx+f407创建工程,创建start_task和isr_task任务,在isr_task任务中portDISABLE_INTERRUPTS()函数无法关闭TIM中断(TIM3 中断优先级设置为4,TIM5中断优先级设置为6),求大神赐教。代码如下: 1、main函数初始化TIM和FreeRTOS [mw_shl_code=applescript,true] MX_TIM3_Init(); MX_TIM5_Init();
/* Call init function for freertos objects (in freertos.c) */ MX_FREERTOS_Init();
/* Start scheduler */ osKernelStart();[/mw_shl_code] 2、任务函数 [mw_shl_code=applescript,true]/* start_task function */ void start_task(void const * argument) { /* USER CODE BEGIN start_task */ /* Infinite loop */ printf("start task\r\n"); taskENTER_CRITICAL(); //??è?áù???? printf("start task ??è?áù????\r\n"); osThreadDef(IsrIask, isr_task, osPriorityHigh, 0, 128); IsrIaskHandle = osThreadCreate(osThread(IsrIask), NULL); vTaskDelete(S atartTaskHandle); //é?3y?aê?è???
printf("start task í?3?áù????\r\n"); taskEXIT_CRITICAL(); //í?3?áù???? /* USER CODE END start_task */ }
/* isr_task function */ void isr_task(void const * argument) { /* USER CODE BEGIN isr_task */ /* Infinite loop */ static uint32_t total_num = 0; for(;;) { total_num+=1; printf("total_num = %d\r\n",total_num); if(total_num==5) { printf("1?±??D??.............\r\n"); portDISABLE_INTERRUPTS(); //1?±??D?? osDelay(5000); //?óê±5s printf("′ò?a?D??.............\r\n"); //′ò?a?D?? portENABLE_INTERRUPTS(); } LEDx_StateSet(LED2,LED_TOGGLE); osDelay(100); } /* USER CODE END isr_task */ }[/mw_shl_code] 3、定时器中断服务函数 [mw_shl_code=applescript,true]void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { if(htim==(&htim3)) { printf("TIM3ê?3?.......\r\n"); } else if(htim==(&htim5)) { printf("TIM5ê?3?.......\r\n"); } }[/mw_shl_code]
|