I run the simple FreeRTOS code, in which program wait for five seconds for MYTASK_Bit to clear, and then create a task “vMyTask”, which execute printf repeatedly with delay of one seconds.
The program runs fine and do what it is supposed to do.
I have two questions:
1. I have set MYTASK_Bit, which is first bit, to 1 (#define MYTASK_Bit (1 << 0)). Does’nt this means that the program should find it as “SET” (as its value is 1) and not wait for five seconds?
2. If I set MYTASK_Bit to 0 (#define MYTASK_Bit (0 << 0)), I get the error :
assert failed: xEventGroupWaitBits event_groups.c:371 (uxBitsToWaitFor != 0). What does it means? My code is as below:
You don’t set a bit here Shifting a 0 by 0 bit positions gives a … 0.
In case you intended to set a bit to 1 as you’ve to because it’ s required by xEventGroupWaitBits as documented.
And you can combine them if you wait for 2 bits as e.g. BIT_0|BIT_1.
Note that the highest 8 bits are reserved for the API’s. Which 8 bits these are depends on the size of TickType_t:
MYTASK_Bit is just a constant which does not have to do anything with event group. When you call xEventGroupSetBits( ev, MYTASK_Bit), first bit of the event group will be set.
Yes, a bit can only be 0 or 1.
You probably want to say that when you create an event group, all the bits are zero unless you explicitly set a bit by calling xEventGroupSetBits. If so, yes you are right.