When I created a task,the task created and run success.Then It,s delete itself.
But when i created it again,the xTaskCreate function return errCOULDNOTALLOCATEREQUIREDMEMORY.
So ,I think the problem is that I delete the function without free memory.
So,How to free the "usStackDepth" memory ?
And i see the task vTaskDelete description:The idle task is responsible for freeing the RTOS kernel allocated memory from tasks that have been deleted.
So it means the idle task not be executed in my project?
That is possible, do you have some task that doesn't block, but sits in a polling loop? That will keep the idle task from running as you never give it a chance. (Note, calling taskYield() will NOT let a lower priority task run, only tasks of the same priority, this is a common misconception).
It is also possible that your heap has gotten fragmented by other allocations, blocking the new allocation from succeeding.
I rarely delete tasks, if I am going to need them again, I have them do their work, and then wait on something (queue/semaphore) to tell them to do their work again, as it can be difficult to code in the chances of tasks not being able to be created due to heap exhaustion/fragmentation (I normally try to have NO usage of the heap once the system is up and operational).
Thanks for your answer.
I have solved the problem.
1.add micro blow in FreeRTOSConfig.h
define #define INCLUDE_xTaskGetIdleTaskHandle 1
2.Because one task never be in wait except high task run.So the idle task never run.so i add taskDelay function in it.
It,s indeed to free memory by calling idle task.
Oh, I quite agree with your point about the task deleting.I will consider to change my code.Thank you.
Your 1. isn't needed, it enables the creationg of a function xTaskGetIdleTaskHandle() to get the handle used for the IdelTask (perhaps to get run-time stats on it).
My general rule is any task that doesn't naturally have a block for something, (and thus will try to run continiously) should be at the Idle priority (0), and thus will share time with the Idle task. These sort of tasks are generally fairly rare, and are mostly background cleanup tasks (Like Idle is for FreeRTOS).
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.