Event in interruption

Hello,

I’m working on STM32WB55, with CMISV2.

I have on interrupt set by a GPIO PA2 with a priority of 8.
I have task at priority of 2 who waiting an event.
The event is set when PA2 rising UP.
The problem is xEventGroupWaitBits never trig in my task.
I’ve made some test and he trigerred when is an another task who set the event.
I don’t understand why is not triggered on the interruption.
I don’t know if it’s a configuration error, or priority issue …

Some of my code :

#define COM_EVENT_READY           1
#define COM_EVENT_NOT_READY       2

#define COM_EVENT_GROUPE    ( COM_EVENT_READY    \
                                | COM_EVENT_NOT_READY)
void COM_init(void)
{
	// Initialisation de la communication SPI entre les microcontroleur
	COM_spi_drv_init();

	COM_events = xEventGroupCreate();
	if(COM_events == NULL)
	{
		Error_Handler();
	}

	if(xTaskCreate (COM_mdw_task_SPINew, "SPI_TH", 256, NULL, 2, NULL) != 1)
	{

	}

//	if(xTaskCreate (COM_mdw_task_Test, "TEST", 256, NULL, 15, NULL) != 1)
//	{
//
//	}
}

void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin)
{
	switch(GPIO_Pin)
	{
	case ITR_SPI_READY_Pin:		//GPIO_PIN_2
	{
		GPIO_PinState state = HAL_GPIO_ReadPin(ITR_SPI_READY_GPIO_Port, ITR_SPI_READY_Pin);
		if(state == GPIO_PIN_SET)
		{
			COM_mdw_masterReady();
		}
		else
		{
			COM_mdw_masterNotReady();
		}
	}
		break;
	default:
	break;
	}
}

void COM_mdw_masterReady(void)
{
	if(COM_events != NULL)
	{
		portBASE_TYPE pxHigherPriorityTaskWoken = pdFALSE;
		if (xEventGroupSetBitsFromISR (COM_events, COM_EVENT_READY, &pxHigherPriorityTaskWoken) != pdFAIL)
		{
			portYIELD_FROM_ISR (pxHigherPriorityTaskWoken);
		}
	}
}

void COM_mdw_masterNotReady(void)
{
	if(COM_events != NULL)
	{
		portBASE_TYPE pxHigherPriorityTaskWoken = pdFALSE;
		if (xEventGroupSetBitsFromISR (COM_events, COM_EVENT_NOT_READY, &pxHigherPriorityTaskWoken) != pdFAIL)
		{
			portYIELD_FROM_ISR (pxHigherPriorityTaskWoken);
		}
	}
}

void COM_mdw_task_SPINew(void *params)
{
	(void)params;

	EventBits_t events;
	const TickType_t xTicksToWait = 1500 / portTICK_PERIOD_MS;

	while(1)
	{
		events = xEventGroupWaitBits (COM_events, COM_EVENT_GROUPE, pdTRUE, pdFALSE, xTicksToWait);
		__asm("nop");

		if ((events & COM_EVENT_READY) != 0)
		{
			MAP_write_Q1(Q1_LED_LEXAN_LOCAL_INDEX,1);
		}

		if ((events & COM_EVENT_NOT_READY) != 0)
		{
			MAP_write_Q1(Q1_LED_LEXAN_LOCAL_INDEX,0);
		}

//		if(events == 0)
//		{
//			xEventGroupSetBits(COM_events,COM_EVENT_READY);
//		}
	}
}

I will be glad if someone can help me.

Olivier

First (hardware) interrupt and (software/logical) task priorities are different, unrelated things.
Did you verify that the interrupt IS triggered as expected e.g. by setting a breakpoint in the ISR ?
Did you configure configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY and the related settings correctly with regard to your MCU and (NVIC) interrupt priorities used ?
So far your code looks ok and should work…

I also strongly recommend to define configASSERT and also enable stack overflow checking for development/debugging in case it’s not already done.

One more hint: For direct ISR to task signaling you could use task notifications. It’s the fastest and lean way for this purpose.

thanks for the answer.

The ISR worked well.
i’ve got this :
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5

I will look the task notifications

I’m using now the task notifications and all is good.
Thank you for showing me this.