taskYIELD fromTickHook

Is any restrictions calling taskYIELD from TickHook? freertos version v4.1.0 ATMEGA GCC port >>-This code is working->> SIGNAL( SIG_OVERFLOW0 ) { portBASE_TYPE xTaskWoken = pdFALSE;     TCNT0 = 125;     TmrTickCtr++;     if (TmrTickCtr >= TMR_DLY_TICKS)     {         TmrTickCtr = 0;       xTaskWoken = xSemaphoreGiveFromISR( TmrSemTenths, xTaskWoken );          } if( xTaskWoken != pdFALSE )      {     taskYIELD ();      } } >>-but this code not->> void vApplicationTickHook( void ) { portBASE_TYPE xTaskWoken = pdFALSE;     TmrTickCtr++;     if (TmrTickCtr >= TMR_DLY_TICKS)     {         TmrTickCtr = 0;       xTaskWoken = xSemaphoreGiveFromISR( TmrSemTenths, xTaskWoken );          } if( xTaskWoken != pdFALSE )      {     taskYIELD ();      } } stack underflow at vPortYieldFromTick()

taskYIELD fromTickHook

Yes there are restriction – on most ports this is definitely not a good idea.  In fact calling yield from any isr is not a good idea unless you use the macros provided in portmacro.h to do so, and follow the examples in the demos. The actual answer is dependent on the port you are using.  Each port yields in a different way. In most cases yielding from the tick hook will not actually perform any useful function.  This is because the tick hook is called prior to the yield being performed by the tick itself.  Therefore if you hook wakes a task, then the tick code itself will yield if the woken task has a higher priority than the task that was interrupted.