Page 1 of 1

xEventGroupSetBits and task scheduler

Posted: Sat Dec 15, 2018 12:02 am
by fly135
Does calling xEventGroupSetBits cause the scheduler to immediately check tasks or does it still run at 10msec intervals. Asking for a friend. :lol:

My coworker wants to sample the ADC at 1khz. The ADC read is in a task and he uses a 1khz timer callback to call xEventGroupSetBits. I'm thinking that it does not invoke the scheduler immediately, and think we should read the ADC in an interrupt routine. Are there any caveats to reading the ADC in an interrupt? It doesn't say anything in the docs WRT that.

John A

Re: xEventGroupSetBits and task scheduler

Posted: Tue Dec 18, 2018 3:55 pm
by fly135
At the very minimum, can I use the adc read routine in an interrupt. I realize the other question is a FreeRTOS thing and may be best asked on a FreeRTOS forum.

Re: xEventGroupSetBits and task scheduler

Posted: Wed Dec 19, 2018 2:47 am
by ESP_Sprite
I just checked: xEventGroupSetBits uses xTaskRemoveFromUnorderedEventList to unblock a task, and that is pre-emptive (as in: will actively switch over to the unblocked task or tell the other core to do so).

In general, all FreeRTOS functions that unblock a higher priority task should immediately switch to that task. (If they don't, things like tickless operation would be impossible.)

Re: xEventGroupSetBits and task scheduler

Posted: Wed Dec 19, 2018 4:30 am
by fly135
Awesome! That makes sense according to what I saw in the semaphore thread.