groufosse wrote on Tuesday, January 08, 2013:
Richard,
Responses to your questions here: “>”
Does it have more than one return point?
>No - just one at the end, no other exit.
Can you step through the function in the debugger to see what it is doing?
> Yes. The debugger just seems to “stop” when it hits any code inside a loop (see example below)
Does it make any use of FreeRTOS API functions?
>Not in the function that’s called. See below
Why would placing it in a critical section make any difference?
> I am completely at a loss to explain this.
It’s important to note that this issue has nothing to do with using sprintf or the CMSIS _DBG_ call. If I comment out all sprintf and DBG calls in my code it will still not run. The only thing that will make it run ( the real function or the “test” function below, is wrapping the call with portENTER_CRITICAL()
I have created a simple function to call from the task handler that might exemplify what is going on. There is a simple 2D array and function. If I run it as is, (#if 1) it will print out this much of the string:
myArray
And that’s it. If I set the preprocessor directive to #if 0, and un-comment the line that starts with “sprintf” above, it prints the line no problem. So it seems like it can print or process something simple, but as soon as a test condition or loop is incurred, it won’t run.
int myArray = { {12,23,33}, {21,44,32},{18,15,76},{89,65,11},{41,19,98},{75,47,53} };
int dataReceiveProcess2(void)
{
char msgBuf;
//sprintf(msgBuf, “myArray= %i”, 2,0, myArray); _DBG_(msgBuf);
#if 1
for(int i = 0; i < 7; i++)
{
sprintf(msgBuf, “myArray= %i”, i,0, myArray_);
_DBG_(msgBuf);
}
#endif
return 0;
}
Here’s the call from main:
static void prvReadCOMBufferTaskFunction( void *pvParameters )
{
portTickType xLastCheckTime;
// Initialize xLast***Times prior to the first call to vTaskDelayUntil()
xLastCheckTime = xTaskGetTickCount();
for(;
{
vTaskDelayUntil( &xLastCheckTime, check_COM_SIGNAL_RATE );
// Check the flag to see if it’s set
if(TRUE == completeFlag)
{
//a small interval for interrupt to complete
vTaskDelay( 50 / portTICK_RATE_MS );
//portENTER_CRITICAL();
//{
dataReceiveProcess2();
completeFlag = FALSE;
//}
}
}
}
_