Quality RTOS & Embedded Software

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


Loading

trace Hook Macros

Posted by youmnahaque on December 20, 2010
HI,
i am using FreeRTOS on Avr32 UC3A0512 .
I tried many methods to use traceTASK_SWITCHED_OUT() or traceTASK_SWITCHED_IN(), but could not succeed.
configUSE_APPLICATION_TASK_TAG is defined 1 in FreeRTOSConfig.h file.
static portBASE_TYPE pTaskHook( void * pvParameter ) {
portTickType c;
c = xTaskGetTickCount();
tickarray = c;
i++; //tick array and i are global variables.
return 0;
}

static void start_task(void)
{
int i;
// Register our callback function.
vTaskSetApplicationTaskTag( NULL, pTaskHook );
while(1){
// task body
}
}

what is the exact place to define the Macro #define traceTASK_SWITCHED_OUT() xTaskCallApplicationTaskHook( pxCurrentTCB, 0 ). i tried it in FreeRTOS.h, and in the main.c but nothing works.
Can someone help me please?

thanks
/Rafia.

RE: trace Hook Macros

Posted by Richard on December 20, 2010
I have actually just written two new sections to the FreeRTOS tutorial book, one of which is specifically on the trace hook macros [these are not in the books currently available, but will get rolled out edition by edition in the new year].

The best place to define hook macros, such as traceTASK_SWITCHED_OUT(), is in FreeRTOSConfig.h. That way the order in which macros are defined is guaranteed to be correct. If you are going to write complex macros then you can put them in their own header file, and include that header file from FreeRTOSConfig.h.

The task hook function is only really required if you want each task to execute a different function. If ever task is to execute the same function you can call the function directly from your definition fo traceTASK_SWITCHED_OUT().

See the following page for more examples (if you have not done so already):
http://www.freertos.org/rtos-trace-macros.html

Regards.

RE: trace Hook Macros

Posted by Mohammad on August 19, 2012
Hi Richard,
i tried to define the macros in FreeRTOSConfig.h, but it did not work.

here is the code.

void log_event(char *Buffer);
char TraceBuffer[2000];


#define traceTASK_SWITCHED_IN() log_event(TraceBuffer)
void log_event(char *Buffer)
{
static int i=0;
TraceBuffer=pxCurrentTCB->pcTaskName[0];
i++;
}
i just want only to have the first letter of each taskname.
the error here is that the "pxCurrentTCB" is stil not defined in FreeRTOS.config
that is why, i tried it in tasks.c after the definition of pxCurrentTCB, and it works and log alle the switches.

but how can i use the pxCurrentTCB in the main.c ? is there a posibility?

Regards

RE: trace Hook Macros

Posted by Richard on August 19, 2012
pxCurrentTCB can be used in main by externing it "extern void *pxCurrentTCB", but it won't do you much good because the (deliberate) data hiding policy used in FreeRTOS will note expose the structure members to you. If you define a macro that uses pxCurrentTCB, and that macro is defined in FreeRTOSConfig.h but called in tasks.c, then you can access the structure members because the code is in effect inlined in tasks.c (which contains the full TCB structure definition).

Regards.


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 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.


Careers

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

Renesas

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