Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create an event group in FreeRTOS.
FreeRTOS
EventGroupHandle_t [1] = xEventGroupCreate(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a queue or task handle variable name instead of an event group handle.
Not assigning the return value of xEventGroupCreate() to a variable.
✗ Incorrect
The function xEventGroupCreate() returns a handle to an event group, which we store in eventGroup.
2fill in blank
mediumComplete the code to wait for an event bit to be set in the event group.
FreeRTOS
EventBits_t bits = xEventGroupWaitBits(eventGroup, [1], pdTRUE, pdFALSE, portMAX_DELAY); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0x00 which waits for no bits.
Using 0xFF which waits for all bits set.
✗ Incorrect
The bit mask 0x01 waits for the first event bit to be set.
3fill in blank
hardFix the error in the code to set an event bit in the event group.
FreeRTOS
xEventGroup[1]Bits(eventGroup, 0x01);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ClearBits' which clears bits instead of setting.
Using 'WaitBits' which waits for bits instead of setting.
✗ Incorrect
The function to set bits in an event group is xEventGroupSetBits().
4fill in blank
hardFill both blanks to create an event group and check if a specific bit is set.
FreeRTOS
EventGroupHandle_t [1] = xEventGroupCreate(); if (xEventGroupGetBits([2]) & 0x02) { // Event bit 2 is set }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for creation and checking.
Using a queue or task handle instead of an event group handle.
✗ Incorrect
We create the event group with myEventGroup and check its bits using the same handle.
5fill in blank
hardFill all three blanks to set multiple event bits and then clear one bit.
FreeRTOS
xEventGroupSetBits([1], 0x03); xEventGroupClearBits([2], [3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different handles for set and clear functions.
Clearing the wrong bit mask.
✗ Incorrect
We set bits 0 and 1 with 0x03, then clear bit 0 with 0x01 on the same event group handle.