sadegh916 wrote on Thursday, July 19, 2018:
Dear friends, Hi
I have a simple code that turn on two LED in two seprated task. It doesn’t work. I debuge an i found that only one task execute. In fact execute the tast which was made first.
please help me. I’m new in FreeRTOS
/* Includes ------------------------------------------------------------------*/ #include "stm32f4x7_eth.h" #include "netconf.h" #include "main.h" #include "tcpip.h" #include "Serial.h" #include "LED.h" #include "task.h" /*--------------- Tasks Priority -------------*/ #define MAIN_TASK_PRIO ( tskIDLE_PRIORITY + 1 ) #define LED1_TASK_PRIO ( tskIDLE_PRIORITY + 3) #define LED2_TASK_PRIO ( tskIDLE_PRIORITY + 4) /* Private function prototypes -----------------------------------------------*/ void Main_task(void * pvParameters); void ToggleLed1(void * pvParameters); void ToggleLed2(void * pvParameters); xTaskHandle ToggleLedHandle1; xTaskHandle ToggleLedHandle2; int main(void) { /* Configures the priority grouping: 4 bits pre-emption priority */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); /* Init task */ xTaskCreate(Main_task, (int8_t *)"Main", configMINIMAL_STACK_SIZE * 2, NULL,MAIN_TASK_PRIO, NULL); /* Start scheduler */ vTaskStartScheduler(); /* We should never get here as control is now taken by the scheduler */ for( ;; ); } void Main_task(void * pvParameters) { SER_Init(); LED_Init(); /* Start toogleLed4 task : Toggle LED4 every 250ms */ xTaskCreateStatic(ToggleLed1, (int8_t *)"LED1", configMINIMAL_STACK_SIZE, NULL, LED1_TASK_PRIO, &ToggleLedHandle1); xTaskCreateStatic(ToggleLed2, (int8_t *)"LED2", configMINIMAL_STACK_SIZE, NULL, LED2_TASK_PRIO, &ToggleLedHandle2); for( ;; ) { vTaskDelete(NULL); } } /** * @brief Toggle Led4 task * @param pvParameters not used * @retval None */ void ToggleLed1(void * pvParameters) { while(1){ LED_On(1); } } void ToggleLed2(void * pvParameters) { while(1){ LED_On(0); } }