Yes, You are right. Only that Particular Group Event bit is erased in case “xClearOnExit” is “True” in case of “xEventGroupWaitBits” Function call.
I found that “xEventGroupSetBits” is triggered x times but only half of the time, the Event Group bit is not getting set. I could also observed that this is happening because this bit is getting cleared at the end of Function Call “xEventGroupSetBits”.
see below Pic.
I have added three Counters: -
Counter20ms1_Timer_A → Counting the number of times the Function “xEventGroupSetBits” is triggered.
Counter20ms1_Timer_B → Counting the number of times the Group event bit is actually set.
ClearbitCount → Counting the number of times the Group Event bit is cleared in the function call “xEventGroupSetBits”.
You can see that Counter20ms1_Timer_A = Counter20ms1_Timer_B + ClearbitCount.
Can you let me know when this bit is cleared in the Function and If you can figure something out from my observation.
I assume it is in continuation to this post → Yes, Sorry I was trying to send you a DM.
What is the priority of the timer task? Make it the highest priority so that nothing can run clear the bit set by xEventGroupSetBits → Yes, I have the maximum number of priorities as 5, Timer Task Priority is the highest i.e. 4 and the 20ms Task has the priority as 3. I am still facing the Problem.
Can you try to trace how is this becoming set on the second line? If you are not able to debug that, drop me a DM with you email and we can setup a debug session. To drop a DM, click on the image next to my display name aggarg and then click Message in the popup.
@aggarg
I was Passing pdFLASE to xClearOnExit in xEventGroupWaitBits and clearing the Event bit using xEventGroupClearBits as shown in below pic but you said that this is not correct in the previous posts (This was resolving my Issue).
Now I am passing pdTRUE to xClearOnExit in xEventGroupWaitBits and I have the Issue as seen in the below Pic. Just FYI : The Event Group bit is getting cleared in xEventGroupSetBits in the below pic.
Dropping the Software for you. OS_Test.zip (1.1 MB)
I did not say that it was not correct. I said that your explanation was incorrect. More specifically, when you set xClearOnExit to pdTRUE, only the bits you are waiting for get cleared. And therefore, the following line in your previous explanation is incorrect -
When you set xClearOnExit to pdTRUE, your clearBitCount variable is expected to increase. The reason that you see it increased only half the time is because your task is running slow and is not calling xEventGroupWaitBits enough number of times. It should be easy to verify by removing the delay loops from the task. If it is determined, it is a CPU performance issue as I suggested before.
→ Got it
Q1) Can I use this method for my Real-Time Application??
Q2) If CPU Performance issue is the problem than why is the execution proper in case of the above implementation where I pass pdFALSE to xClearOnExit in xEventGroupWaitBits and then clear the Event bit using xEventGroupClearBits. I should be facing the same Issue?
Yes, It can be CPU performance issue.
→ When I remove the Delay Loop, I can see no problem.
Q3) When I have the Delay loop of 5ms or use non blocking RTOS Delay of 5ms using vTaskDelay(), I am still facing the same Issue in both the cases → Why can I still see the issue in case I add non-blocking delay??
Q4) I have only a single task of 20ms having a 5ms non-blocking delay as runnable using vTaskDelay() → Should this cause a CPU overload??
Q5) The CPU performance Issue you are talking about is CPU Overload??
Q6) Why Counter20ms1_Timer_B is 0. It should be same asCounter20ms1_Task to my understanding?
Q1) Can I use this method for my Real-Time Application??
Yes, if it suits your application need.
Q2) If CPU Performance issue is the problem than why is the execution proper in case of the above implementation where I pass pdFALSE to xClearOnExit in xEventGroupWaitBits and then clear the Event bit using xEventGroupClearBits. I should be facing the same Issue?
How are you verifying that?
Q3) When I have the Delay loop of 5ms or use non blocking RTOS Delay of 5ms using vTaskDelay(), I am still facing the same Issue in both the cases → Why can I still see the issue in case I add non-blocking delay??
It does not matter what type of delay you use. Bottom line is that your task is not able to call xEventGroupWaitBits enough number of times.
Q4) I have only a single task of 20ms having a 5ms non-blocking delay as runnable using vTaskDelay() → Should this cause a CPU overload??
Q5) The CPU performance Issue you are talking about is CPU Overload??
It is not overload but speed.
Q6) Why Counter20ms1_Timer_B is 0. It should be same asCounter20ms1_Task to my understanding?
No - every time when timer callback sets the bit by calling xEventGroupSetBits, if finds the corresponding task waiting and therefore clears the bit (because clear on exit is true). So there is no case where the bit is not cleared upon return from xEventGroupSetBits.
xClearOnExit is disabled and Event group bit is erased using xEventGroupClearBits. Issue cannot be seen. If there was a CPU Performance Issue and xEventGroupWaitBits are missing. Then, Counter20ms1_Timer_A should be not same as Counter20ms1_Task
→ What does this mean(Speed Issue)?
→ The CPU is currently operating at 80MHz speed, Does this mean that we cannot use a high execution time runnable in our Task or we cannot such small TICK time(1ms) ??
→ Should I try to increase the clock for configCPU_CLOCK_HZ and test?? → (I increased the CPU Clock to 120MHz from 80MHz but still saw the same Issue)
→ What can be done to solve this Issue??
I get the following with xClearOnExit set to pdFALSE:
However, these results depends a lot on timing and therefore, can vary between platforms. To get a detailed understanding of what is going on your platform, you should use a tool like Tracelyzer.
What does this mean(Speed Issue)?
Assuming that my guess is correct, what I mean is that the CPU is taking more time to execute code in task and as a result, wait bits is not called enough number of times.