vTaskStartTrace buffer data size

natanel wrote on Friday, January 18, 2008:

Hi

I am using vTaskStartTrace to trace tasks switch.
and sending the data through the usb port which then is read and plot in matlab.

code:
#if ( configUSE_TRACE_FACILITY == 1 ) //debug
if((sxUSBMessage.sValue1 & TASKS_TRACE_DEBUG)==TASKS_TRACE_DEBUG)   
{
void * pvBuffer;
unsigned portLONG ulBufLength;

// write task list
vTaskList( (  (signed portCHAR *)(&(scDebugBuff[0])) ) );           

// length of written data
ulBufLength=ulGetBufferLength(); //just return trace buf length in byte with out stoping trace
                       
// place of putting length of data
pvBuffer=((void *)(&(scDebugBuff[DEBUG_BUF_LENGTH-sizeof( unsigned portLONG )])));
// putting length of data
*( unsigned portLONG * ) pvBuffer = ( unsigned portLONG ) ulBufLength;
                       
// start new trace
ulTaskEndTrace();
pvBuffer=((void *)(&(scDebugBuff[DELTA_TASK_LIST])));
vTaskStartTrace( ((signed portCHAR *)(pvBuffer)),DEBUG_BUF_LENGTHDELTA_TASK_LIST-sizeof( unsigned portLONG ));
                       
// send trough USB
Usb_write_endpoint_in( (unsigned char *)scDebugBuff, DEBUG_BUF_LENGTH, DEBUG_BUF_LENGTH, ONE_SEC_TIMERATE>>2);
}   
break;
#endif   

from matlab size it look like that
dummy request for debug
pause 200 msec
request for debug
pause 200 msec
request for debug
pause 200 msec
request for debug
pause 200 msec
request for debug
pause 200 msec
request for debug

getting 1 around sec of tasks switch trace

then looking on the data at matlab it is two 32 bit size numbers one tick time/number and second tasks num
which is a waste of space (for up to 6 tasks switch in one msec and tracing for up to 500 msec it is 8*6*500=24000 byte in mcu RAM)
task num can be 8 bit size (up to 255 tasks)
(and time can be one 32 bit start time and then 16 bit delta times)

I tried to modify it by changing the define

/*
* Macro that writes a trace of scheduler activity to a buffer.  This trace
* shows which task is running when and is very useful as a debugging tool.
* As this macro is called each context switch it is a good idea to undefine
* it if not using the facility.
*/
#if ( configUSE_TRACE_FACILITY == 1 )
#define vWriteTraceToBuffer()                                                                   
{                                                                               
if( xTracing )                                                                           
{                                                                               
static unsigned portBASE_TYPE uxPreviousTask = 255;                                                           
if( uxPreviousTask != pxCurrentTCB->uxTCBNumber )   
{                                                                                       
if( ( pcTraceBuffer + tskSIZE_OF_EACH_TRACE_LINE ) < pcTraceBufferEnd )               
{                                           
uxPreviousTask = pxCurrentTCB->uxTCBNumber;                       
*( unsigned portLONG * ) pcTraceBuffer = ( unsigned portLONG ) xTickCount;       
pcTraceBuffer += sizeof( unsigned portCHAR ); /* was portLONG */            
*( unsigned portCHAR * ) pcTraceBuffer = ( unsigned portCHAR )uxPreviousTask;    /* was portLONG */ 
pcTraceBuffer += sizeof( unsigned portLONG );                                   
}                           
else                               
{                               
xTracing = pdFALSE;                       
}                           
}                           
}                           
    }

#else

    #define vWriteTraceToBuffer()

#endif

in task.c

but this just freeze my MCU (evk110 board-atmel 32bit U3A)

any ideas were and how to do it right

regards
Natanel

davedoors wrote on Saturday, January 19, 2008:

On ARM processors you have to use 32bit types otherwise you will generate an exception due to unaligned access. I’m not sure if the same is true for AVR32 though.