This explanation does not seem correct to me - when a task is blocked waiting for a bit, it does not consume CPU and it is ready to run state as soon as that bit is set.
@aggarg Yes, I am not sure how changing this parameter resolved this Issue. Please let me know if you have any understanding of why this worked. Thanks
The best I can guess is that there is a problem somewhere else and changing the wait parameter just masks it. But again, it is just a guess - I’d recommend to first figure out the root cause and then apply any solution.
Hello @aggarg
I think I found the Issue. Please let me know if this is correct.
Old Code - Not Working
Updated Code - Working
→ update has been highlighted.
→ In the Older Code, I think the problem was when 50ms Task Event Group bit was read then It will clear the 20ms Task Event Group bit as well. Therefore, this will cause the 20ms Task to drop.
→ In the new code, I am not clearing the Event Group bits on reading but doing it manually as can be seen in the code.
Please let me know if my understanding is correct. Thanks
That is not correct. The following is from the documentation of xEventGroupWaitBits:
xClearOnExit If xClearOnExit is set to pdTRUE then any bits set in the value passed as the uxBitsToWaitFor parameter will be cleared in the event group before xEventGroupWaitBits() returns if xEventGroupWaitBits() returns for any reason other than a timeout. The timeout value is set by the xTicksToWait parameter.
If xClearOnExit is set to pdFALSE then the bits set in the event group are not altered when the call to xEventGroupWaitBits() returns.
You can also see the code here that only bits in the uxBitsToWaitFor
are cleared - https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/event_groups.c#L356
HI,
I am new to this community and was really interested with logic you have written here. Could you please share the full app_main.c file?
Thanks,
Rahul
Are you looking for the file attached in this reply?
Hi,
Thanks for quick response. I was looking for teh whole project, meaning your configuration and the source code after modifications.
Thanks,
RAhul
I do not have the as the OP only shared this file in the discussion. @SaktiPadhy can help with that. Alternatively you can look into a lot of examples that we provide here - FreeRTOS/FreeRTOS/Demo/Common/Minimal at main · FreeRTOS/FreeRTOS · GitHub
Thanks,
That helps.
I am actually trying to learn implement 4-5 tasks waiting on Timer based event. It could be independant timers like 1ms, 5ms, 10ms, 20ms, 100ms timers. If there is some example to look for in this regard will be very helpful.
Thanks,
Rahul
If you wanna use timers, you can look at the example provided on this page - FreeRTOS - Open Source software for microcontrollers - FreeRTOS xTimerCreate() API function description
If you want 5 independent tasks executing periodically, you can use vTaskDelay - This page describes the RTOS vTaskDelay() FreeRTOS API function which is part of the RTOS task control API. FreeRTOS is a professional grade, small footprint, open source RTOS for microcontrollers.