0
0
FreeRTOSprogramming~10 mins

Trace hooks and FreeRTOS+Trace - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a trace hook function that runs when a task is switched in.

FreeRTOS
void traceTASK_SWITCHED_IN(void) {
    [1];
}
Drag options to blanks, or click blank then click option'
Aprintf("Task switched in\n")
BvTaskDelay(10)
CxTaskCreate()
DvTaskDelete(NULL)
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to create or delete tasks inside the trace hook.
Using delay functions inside trace hooks.
2fill in blank
medium

Complete the code to enable FreeRTOS+Trace recording in the configuration.

FreeRTOS
#define configUSE_TRACE_FACILITY [1]
Drag options to blanks, or click blank then click option'
A0
B2
C3
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the value to 0 disables tracing.
Using values greater than 1 which are not valid.
3fill in blank
hard

Fix the error in the trace hook function to correctly record a task switch event.

FreeRTOS
void traceTASK_SWITCHED_OUT(void) {
    [1](pxCurrentTCB->pxTaskTag);
}
Drag options to blanks, or click blank then click option'
AvTraceStart
BvTraceStoreTaskSwitchedOut
CxTaskCreate
DvTaskDelay
Attempts:
3 left
💡 Hint
Common Mistakes
Using delay or task creation functions inside trace hooks.
Calling functions unrelated to tracing.
4fill in blank
hard

Fill both blanks to create a dictionary of task names and their run times using FreeRTOS+Trace API.

FreeRTOS
for (int i = 0; i < uxTaskGetNumberOfTasks(); i++) {
    char* name = pcTaskGetName([1]);
    uint32_t time = ulTaskGetRunTimeCounter([2]);
    taskTimes[name] = time;
}
Drag options to blanks, or click blank then click option'
Ai
BpxCurrentTCB
CNULL
DxTaskGetHandle(NULL)
Attempts:
3 left
💡 Hint
Common Mistakes
Using NULL or current task handle instead of the loop index.
Mixing task handles and indexes incorrectly.
5fill in blank
hard

Fill all three blanks to start trace recording, record a task switch, and stop recording.

FreeRTOS
vTrace[1]();
vTrace[2](pxCurrentTCB->pxTaskTag);
vTrace[3]();
Drag options to blanks, or click blank then click option'
AStart
BStoreTaskSwitchedIn
CStop
DReset
Attempts:
3 left
💡 Hint
Common Mistakes
Using reset instead of stop to end trace.
Not calling the store function for task switch.