FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [December 2010 Threads] trace Hook MacrosPosted 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 MacrosPosted 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 MacrosPosted 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 MacrosPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|