Do i have to call portYield multiple times in ISR?

I know that while using RTOS api in ISR i have to check for higher priority task for context switching.

My question here is, i am calling 2 api function in ISR, as below

xQueueSendFromISR( state, void * ) &lu8Command,
						&xHigherPriorityTaskWoken);

and 
xEventGroupSetBitsFromISR(status, BIT_TX_DONE,
				&xHigherPriorityTaskWoken);

So how do i handle

		if (xHigherPriorityTaskWoken) {
			portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
		}

Do i have to call i twice after every api call or calling it once is safe ?

The thing is that the FromISR functions only set the xHigherPriorityTaskWoken to pdTRUE if applicable. Hence the variable must be initialized to pdFALSE.
So it’s designed to call it just once or alternatively simply the portEND_SWITCHING_ISR wrapper at the end of the ISR.

1 Like

Hey @hs2 Thanks for reply

sorry i got occupied with some other work. So i should call portEND_SWITCHING_ISRTRUE at end ?

also do i have to call FromISR from freertos timer callback ?

Yes, that is right.

Do you mean portEND_SWITCHING_ISR? If so, no, you do not need to call it form a FreeRTOS timer callback.

1 Like