Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


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 ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists