heinbali01 wrote on Saturday, February 18, 2017:
Look here in task.c :
BaseType_t xTaskIncrementTick( void )
TCB_t * pxTCB;
BaseType_t xSwitchRequired = pdFALSE;
/* Called by the portable layer each time a tick interrupt occurs.
Increments the tick then checks to see if the new tick value will cause any
tasks to be unblocked. */
traceTASK_INCREMENT_TICK( xTickCount );
if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
For every tick increment, it calls a macro or a function called
By default, the macro does nothing:
#define traceTASK_INCREMENT_TICK( xTickCount )
Now if you want to do something during every tick-increment, you can define the macro in a new way. Write that new definition in you
FreeRTOSConfig.h file, so it will be included before
extern void vMyTickIncrement( TickType_t xCount );
#define traceTASK_INCREMENT_TICK( xTickCount ) \
vMyTickIncrement( xTickCount ); \
} while( 0 )
When you run this, your function will be called for every increment.
So what you see in FreeRTOS is giving a proper default value for every macro.
Be careful: most trace-macro’s are being called from critical situations. The task scheduler is often temporarily disabled, interrupts might have been disabled. When a trace macro is called from the idle task, there are many things you’re not supposed to do, and the task-stack will be very small.
The good thing about trace macro’s: they avoid the necessity to change the FreeRTOS source code. Regards.