Quality RTOS & Embedded Software

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


Loading

#define in FreeRTOS.h

Posted by eaoiyrioeaf on February 18, 2017

In the FreeRTOS.h file, there are lots of definition as shown in below:

ifndef traceTASKINCREMENTTICK
#define traceTASK_INCREMENT_TICK( xTickCount )
endif

the statement "#define traceTASKINCREMENTTICK( xTickCount )" seems actually doing nothing, I'm not quite understand it. Could anyone kindly help?


#define in FreeRTOS.h

Posted by heinbali01 on February 18, 2017

Look here in task.c :

~~~~ BaseTypet xTaskIncrementTick( void ) { TCBt * pxTCB; TickTypet xItemValue; BaseTypet 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 traceTASK_INCREMENT_TICK().

By default, the macro does nothing:

~~~~

ifndef traceTASKINCREMENTTICK
#define traceTASK_INCREMENT_TICK( xTickCount )
endif

~~~~

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 include/FreeRTOS.h.

~~~~ extern void vMyTickIncrement( TickType_t xCount );

define traceTASKINCREMENTTICK( xTickCount )
do \
{ \
	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.


#define in FreeRTOS.h

Posted by eaoiyrioeaf on February 18, 2017

That help me a lot, Thank you so much!


[ 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