TaskCreate is not working in my project

barry0808 wrote on Wednesday, January 23, 2019:

Hi,
I created two task as below , but only MainTask1 been invoking ,
do I missing something ?

xReturn = xTaskCreate( MainTask1,
             "MainTask1", 
             configMINIMAL_STACK_SIZE, 
             ( void * ) NULL, 
             1, 
             &xHandle1 );

xReturn = xTaskCreate( MainTask2,
             "MainTask2", 
             configMINIMAL_STACK_SIZE, 
             ( void * ) NULL, 
             1, 
             &xHandle2 );

vTaskStartScheduler();

rtel wrote on Wednesday, January 23, 2019:

What is the value of xReturn after the second call to xTaskCreate()?
Maybe you just ran out of heap. Do you have a malloc failed hook defined?

richarddamon wrote on Wednesday, January 23, 2019:

A second possiblility would be does MainTask1 ever block to leave time for MainTask2 to execute?

barry0808 wrote on Wednesday, January 23, 2019:

thanks Richard, you second idea is the case.
I change as below , I can see two tasks get executed.
However , I expected they get executed in turn but they are only get executed once.
and system stuck at “prvCheckTasksWaitingTermination” function.
any idea ?

void MainTask1( void *pvParameters )
{
TickType_t xNextWakeTime;

xNextWakeTime = xTaskGetTickCount();

for( ;; ){

    TRACE0(182, RTOS, 0, "Task1 loop");
	vTaskDelayUntil( &xNextWakeTime,  200 / portTICK_PERIOD_MS );
}

}

void MainTask2( void *pvParameters )
{
TickType_t xNextWakeTime;

xNextWakeTime = xTaskGetTickCount();

for( ;; ){

    TRACE0(182, RTOS, 0, "Task2 loop");
	vTaskDelayUntil( &xNextWakeTime,  200 / portTICK_PERIOD_MS );
}

}

richarddamon wrote on Thursday, January 24, 2019:

Make sure the tick interrupt is running.
That function is called in the idle task, which runs when no other task is ready. The Idle task checks to see if it needs to do any cleanup, does it then checks again, (and so on).