taskYIELD in an ISR

tlafleur wrote on Friday, October 07, 2011:

In the dsPIC33 demo, the serial driver interrupt routine has a taskYIELD, but in the Using the FreeRTOS Real Time Kernel, Sep 2011 edition (for the PIC32) stated that only API that end with FromISR are allowed in ISR… why is this an exception?? and not documented??

thanks…

also, in Microchips MPLAB Ver 8.76 there is a FreeRTOS  viewing tool for displaying information on the current program… It display information on Task and CoRoutines, but never on Queues???  is it outdated??

void __attribute__((__interrupt__, auto_psv)) _U2RXInterrupt( void )
{
char cChar;
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

/* Get the character and post it on the queue of Rxed characters.
If the post causes a task to wake force a context switch as the woken task
may have a higher priority than the task we have interrupted. */
IFS1bits.U2RXIF = serCLEAR_FLAG;
while( U2STAbits.URXDA )
{
cChar = U2RXREG;
xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
}

if( xHigherPriorityTaskWoken != pdFALSE )
{
taskYIELD();
}
}

rtel wrote on Friday, October 07, 2011:

In the dsPIC33 demo, the serial driver interrupt routine has a taskYIELD, but in the Using the FreeRTOS Real Time Kernel, Sep 2011 edition (for the PIC32) stated that only API that end with FromISR are allowed in ISR

The PIC32 book is for the PIC32, which in architecture terms is about as far away from a dsPIC as you can get.  Why would it talk about an exception for a dsPIC any more than it would for a Cortex-M3?

Not calling a function that does not end in FromISR from an ISR is a very good general rule in all cases.  Some, but not many, ports can tolerate taskYIELD() being called from an ISR, provided it is the last instruction in the ISR.  In most cases, where this is the case, the call to taskYIELD() is hidden behind a macro called portYIELD_FROM_ISR(), or portEND_SWITCHING_ISR().  The PIC24/dsPIC port is rather old, and that is probably why it was not done in that case.  The documentation page for that port (http://www.freertos.org/portpic24_dspic.html) does however say how it is done, albeit rather briefly.

also, in Microchips MPLAB Ver 8.76 there is a FreeRTOS  viewing tool for displaying information on the current program… It display information on Task and CoRoutines, but never on Queues???  is it outdated??

See configQUEUE_REGISTRY_SIZE on http://www.freertos.org/a00110.html and
http://www.freertos.org/vQueueAddToRegistry.html

Regards.

gridsense wrote on Friday, October 14, 2011:

We bought two documents from website, I get confused about “xSemaphoreGiveFromISR()”.

1. In document “FreeRTOS Reference Manual”, in page93,
    void VISR( void *pvParameters)
    { ……
      taskYIELD_FROM_ISR( xHigherPriorityTaskWoken);
    }

2. In document " Using the RTOS REal Time Kernel" ARM Cortex-M3 Edition, page 93
  
    void vSoftwareInterruptHandler (void)
    {
      …
     portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
    }.

My question is:
   I can’t find the function prototype for   taskYIELD_FROM_ISR( ) and  portEND_SWITCHING_ISR().
  
Regards
Samuel

richard_damon wrote on Friday, October 14, 2011:

These are macros in port macro.h (for the appropriate port). The exact method used to end an interrupt depends on the port.