Why "xEventGroupSetBitsFromISR" sometimes can not set Event?

Hello all:
Could you please help to analysis the issue about the Event Bit can’t be set from Interrupt by call
API “xEventGroupSetBitsFromISR” ?
For the detail, “Bit reading task -\t Event bit mainISR_BIT was set\r\n” haven’t be printed, and
" xHigherPriorityTaskWoken " was “pdTRUE” , “IsrTrigger” also was “true”,“xEventGroup” was non-NULL value by debug.
Besides, this is a probabilistic issue, some times the "mainISR_BIT” can be set correctly.
Thanks!

static boolean IsrTrigger = false;
static boolean EventCreate = false;
static EventBits_t xEventGroupValue;
#define mainISR_BIT 1UL

static void vEventBitReadingTask( void *pvParameters )
{
	const EventBits_t xBitsToWaitFor = mainISR_BIT;

	if(EventCreate == false)
	{
	  EventCreate = true;
      xEventGroup = xEventGroupCreate();
	}

	/* Block to wait for event bits to become set within the event group. */
	xEventGroupValue = xEventGroupWaitBits(xEventGroup,xBitsToWaitFor,pdTRUE,pdFALSE,portMAX_DELAY );

	if( ( xEventGroupValue & mainISR_BIT ) != 0 )
	{
		vPrintString( "Bit reading task -\t Event bit mainISR_BIT was set\r\n" );
	}
}

static void ulEventBitSettingISR( void )
{
	static BaseType_t xHigherPriorityTaskWoken = pdFALSE;
	
	if(EventCreate == true)
	{
	    IsrTrigger = true;
		xEventGroupSetBitsFromISR( xEventGroup, mainISR_BIT, &xHigherPriorityTaskWoken );
	}
}

One quick thing that I notice is you aren’t USING xHigherPriorityTaskWasWoken at the end of the ISR to decide if you need to do a yield.

It also should NOT be a ‘static’ as that says that it will only be cleared on the first time the ISR is entered, and you want it cleared every time. so you know if THIS interrupt unblocked some task on THIS interrupt.

Hi:
I tried to change the code like follows show, but the result is the same.

static boolean IsrTrigger = false;
static boolean EventCreate = false;
static EventBits_t xEventGroupValue;
#define mainISR_BIT 1UL

static void vEventBitReadingTask( void *pvParameters )
{
	const EventBits_t xBitsToWaitFor = mainISR_BIT;

	if(EventCreate == false)
	{
	  EventCreate = true;
      xEventGroup = xEventGroupCreate();
	}

	/* Block to wait for event bits to become set within the event group. */
	xEventGroupValue = xEventGroupWaitBits(xEventGroup,xBitsToWaitFor,pdTRUE,pdFALSE,portMAX_DELAY );

	if( ( xEventGroupValue & mainISR_BIT ) != 0 )
	{
		vPrintString( "Bit reading task -\t Event bit mainISR_BIT was set\r\n" );
	}
}

static void ulEventBitSettingISR( void )
{
	BaseType_t xHigherPriorityTaskWoken = pdFALSE;
	
	if(EventCreate == true)
	{
	    IsrTrigger = true;
		xEventGroupSetBitsFromISR( xEventGroup, mainISR_BIT, &xHigherPriorityTaskWoken );
		portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
	}
}

Seems this is some test code, right ? A typical task function consists of an optional init part and a forever loop because it can’t return.
Did you verify that all resources like the event group and the task itself are created successfully and runs properly ? You don’t check any error return but you should.
You also should ensure that vEventBitReadingTask along with the event group used in the ISR is created before the ISR is armed (and triggered).
BTW I’d use task notifications in this case for signaling the interrupt.

You are right, it is test code, and I have verified the event grout and tasks are created successfully actually.
In addition, the issue have been fixed. Because I check the API Doc like follows picture.
It is working after changing the macro “configTIMER_TASK_PRIORITY” to “configMAX_PRIORITIES - 1”.
Thanks !