Trace hooks help you watch what your FreeRTOS program is doing step-by-step. FreeRTOS+Trace shows this information in a clear way so you can find and fix problems easily.
Trace hooks and FreeRTOS+Trace
/* Enable trace hooks in FreeRTOSConfig.h */ #define configUSE_TRACE_FACILITY 1 /* Include FreeRTOS+Trace header in your main file */ #include "trcRecorder.h" /* Start trace recording */ vTraceEnable(TRC_START); /* Stop trace recording */ vTraceEnable(TRC_STOP);
Trace hooks are enabled by setting configUSE_TRACE_FACILITY to 1 in FreeRTOSConfig.h.
FreeRTOS+Trace uses special functions to start and stop trace recording. Use the FreeRTOS+Trace tool to retrieve data from the RAM buffer.
/* Enable trace hooks */ #define configUSE_TRACE_FACILITY 1
#include "trcRecorder.h" int main(void) { vTraceEnable(TRC_START); // Start tracing // Your FreeRTOS code here return 0; }
This program enables trace hooks, creates a simple task, starts trace recording, and starts the scheduler. Use the FreeRTOS+Trace tool to read the trace buffer from RAM.
/* FreeRTOSConfig.h snippet */ #define configUSE_TRACE_FACILITY 1 /* main.c */ #include "FreeRTOS.h" #include "task.h" #include "trcRecorder.h" void Task1(void *pvParameters) { for (;;) { // Simulate work vTaskDelay(pdMS_TO_TICKS(100)); } } int main(void) { xTaskCreate(Task1, "Task1", 1000, NULL, 1, NULL); vTraceEnable(TRC_START); // Start trace vTaskStartScheduler(); // Start FreeRTOS scheduler // Normally never reached return 0; }
Trace hooks add a little overhead but help you see what tasks do in real time.
FreeRTOS+Trace shows a timeline of tasks switching, delays, and interrupts.
Always disable trace hooks in production to keep your program fast.
Trace hooks let you watch FreeRTOS tasks and events as they happen.
FreeRTOS+Trace helps you see this information clearly to debug and learn.
Enable trace hooks in config and use vTraceEnable to record data. Retrieve with the tool.