Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


vTaskStartTrace buffer data size

Posted by natanel on January 18, 2008

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

#if ( configUSE_TRACE_FACILITY == 1 ) //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
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);

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; \


#define vWriteTraceToBuffer()


in task.c

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

any ideas were and how to do it right


RE: vTaskStartTrace buffer data size

Posted by Dave on 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.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner