xTaskCreate gets hang when second task is created

Our code gets hang when we use API xTaskCreate() for second time, below is explanation:

  1. Our first task is created with priority tskIDLE_PRIORITY and it is running properly.
  2. Second task is created from first task with priority tskIDLE_PRIORITY were our code gets hang. (Above 2 points condition occur when no scheduler is started)
  3. On debug found that the scheduler is not started, but when we use scheduler before creating our first task of after creating first task the code hangs at vTaskStartScheduler();

What can be the possible reasons for this?

Is there anything we need to change in configuration?

FreeRTOS Kernel V10.0.1

Any help will be appreciated.


Did you enable/define configASSERT ? Where does the code hang ? Do you have a debugger connected ? Then halt the application and check the call stack.
And perhaps post your configs that one could give a hint what to change.

I am not clear on the sequence that results in this error as you cannot create one task from another if the scheduler has not started. However no matter which order you create the tasks in the most likely cause would be running our of heap memory.

Have you checked the xTaskCreate() return value to ensure the task was actually created?