Challenge - 5 Problems
Event-Driven Mastery in FreeRTOS
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Event Group Bits Setting and Clearing
What is the output of this FreeRTOS code snippet that uses event groups to set and clear bits?
FreeRTOS
EventGroupHandle_t eventGroup = xEventGroupCreate(); xEventGroupSetBits(eventGroup, (1 << 0)); xEventGroupSetBits(eventGroup, (1 << 1)); EventBits_t bits = xEventGroupClearBits(eventGroup, (1 << 0)); printf("Bits before clear: 0x%X\n", bits); printf("Bits after clear: 0x%X\n", xEventGroupGetBits(eventGroup));
Attempts:
2 left
💡 Hint
Remember that xEventGroupClearBits returns the bits before clearing.
✗ Incorrect
The code sets bits 0 and 1 (0x1 and 0x2), so before clearing, bits are 0x3. Clearing bit 0 removes 0x1, leaving 0x2.
🧠 Conceptual
intermediate1:30remaining
Understanding Event-Driven Task Notification
In FreeRTOS, which statement best describes the behavior of task notifications used as lightweight event flags?
Attempts:
2 left
💡 Hint
Think about how task notifications combine signaling and data transfer.
✗ Incorrect
Task notifications in FreeRTOS are lightweight and can both unblock a task and carry a 32-bit value atomically without extra queues.
🔧 Debug
advanced2:30remaining
Debugging Event Group Wait Timeout
A task waits for bits 0x01 and 0x02 using xEventGroupWaitBits with the wait option to clear bits on exit. The task never proceeds even though another task sets bit 0x01. What is the most likely cause?
FreeRTOS
xEventGroupWaitBits(eventGroup, 0x03, pdTRUE, pdTRUE, portMAX_DELAY);Attempts:
2 left
💡 Hint
Check the 'wait for all bits' parameter and which bits are set.
✗ Incorrect
The function waits for both bits 0x01 and 0x02 (0x03) to be set. If only 0x01 is set, the wait never completes.
📝 Syntax
advanced1:00remaining
Identify the Syntax Error in Event Group Creation
Which option contains the correct syntax to create an event group in FreeRTOS?
Attempts:
2 left
💡 Hint
Remember that xEventGroupCreate is a function that returns a handle.
✗ Incorrect
Option A correctly calls the function with parentheses. Option A misses parentheses, C uses invalid brackets, A has an extra semicolon but compiles (though stylistically odd).
🚀 Application
expert3:00remaining
Designing an Event-Driven Task Synchronization
You want to synchronize three tasks so that each waits until all three have reached a certain point before continuing. Which FreeRTOS event-driven mechanism is best suited for this?
Attempts:
2 left
💡 Hint
Think about a mechanism that can track multiple flags and wait for all.
✗ Incorrect
An event group allows each task to set a unique bit and wait until all bits are set, effectively synchronizing all tasks at a barrier.