//check to see if start sequence received (startCycle). If started,
//initiate a task that will validate time taken. should never be
//more than 10-12 seconds from start.
if(startCycle )
{
//launch task to check in 10 seconds to see if completeFlag is set
pdPass = xTaskCreate( prvCommCheckTaskFunction, ( signed char * ) “CommCheck”, configMINIMAL_STACK_SIZE, NULL, 2,(xTaskHandle)&CommCheckTask );
sprintf(msgBuf, “pdPass = %i”, pdPass); _DBG_(msgBuf);
}
. if(completeFlag)
{
//found end of sequence; Ok to delete the comm check task.
if(CommCheckTask) vTaskDelete( (xTaskHandle) CommCheckTask );
//then process data
processData();
}
}
Here’s the function callback for the created function: it’s timer is set to 10 seconds
One question, why are you casting CommCheckTask to a xTaskHandle, it should be one already (and casting &CommCheckTask to one is incorrect).
Also, you need to take some care in deleting a task, as doing so stops it right were it is with NO cleanup, so any resources it creates are not released. In your case if it is in the vTaskDelayUntil call you should be ok, but if that ends and you are starting the _DBG call, that might cause problems.
Hi, thanks for the help.
Not sure how that cast got in there? I thought most of my code was from FreeRTOS examples, but none of the other tasks have that cast. Thanks for pointing that out.
When you refer to cleanup, are you referring to FreeRTOS, or my code? If my code, yes, I have other stuff, just a few variables to set, which I would do before the delete. At this point I was just getting it to work repetitiously.
The function “prvReadCOMBufferTaskFunction” has been working with no issues at all before the above.
Any other suggestions - or is it just the task handle you think is causing this?
The casts can only cause trouble if CommCheckTask wasn’t defined as a xTaskHandle.
For cleanup, I was referring to things like allocating memory in the task, or acquiring semaphores.
One other thought is the code you posted doesn’t check that the xTaskCreate call succeeds. It is possible that you run out of memory. A few quick questions, which heap version are you using? Also, is the idle task able to get time to run? In you application it MUST be given time to run, as vTaskDelete does not put the memory from the task back into the heap, but postpones that operation to the idle task. If you have a task, above priority 0, that doesn’t block, you will not get your memory freed.