nilssch wrote on Thursday, July 07, 2011:
Hello,
Im am confused about the usage of “taskYield()” / “portYIeld()” / “portEND_SWITCHING_ISR” within an Interrupt when using a PIC32 port. Thanks in advance for all the support here!
The “PIC32 FreeRTOS reference manual” states (page 99, v6.0) that one may never use “taskYIELD()” within an ISR, but should use portEND_SWITCHING_ISR. However both functions are defined to the same function portYIELD!
/**
* task. h
*
* Macro for forcing a context switch.
*
* \page taskYIELD taskYIELD
* \ingroup SchedulerControl
*/
#define taskYIELD() portYIELD()
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) \
{ \
portYIELD(); \
}
Also I am having trouble with these function when using within an CAN interrupt handler. My ISR sends messages to a queue and an RX task shall receive them. But after a while the task wating on the queue will not wake up although there are elements in the queue. All works fine without usage of portEND_SWITCHING_ISR. Does somebody have an explanation for this?
void __attribute__((vector(46), interrupt(ipl4), nomips16)) CAN1InterruptHandler(void)
{
char temp=0; //This shall be the CAN data to be received
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(xQueueIDCanRx, &temp, &xHigherPriorityTaskWoken);
/* If sending or receiving necessitates a context switch, then switch now.*/
if( xHigherPriorityTaskWoken )
{
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}
}
Best regards,
Nils