HOla:
estoy comenzando a utilizar freertos con un dspic33fj128mc802. Deseo utilizar un semaforo ligado a una interrupccion.
Sin emgaro me confundo un poco como utilizarlo ya que en un ejemplo que vi (de un cortex) viene este ejemplo de uso del semaforo en la interrupcion:
void vSoftwareInterruptHandler( void )
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
/* 'Give' the semaphore multiple times. The first will unblock the handler
task, the following 'gives' are to demonstrate that the semaphore latches
the events to allow the handler task to process them in turn without any
events getting lost. This simulates multiple interrupts being taken by the
processor, even though in this case the events are simulated within a single
interrupt occurrence.*/
xSemaphoreGiveFromISR( xCountingSemaphore, &xHigherPriorityTaskWoken );
xSemaphoreGiveFromISR( xCountingSemaphore, &xHigherPriorityTaskWoken );
xSemaphoreGiveFromISR( xCountingSemaphore, &xHigherPriorityTaskWoken );
xSemaphoreGiveFromISR( xCountingSemaphore, &xHigherPriorityTaskWoken );
/* Clear the software interrupt bit using the interrupt controllers
Clear Pending register. */
mainCLEAR_INTERRUPT();
/* Giving the semaphore may have unblocked a task - if it did and the
unblocked task has a priority equal to or above the currently executing
task then xHigherPriorityTaskWoken will have been set to pdTRUE and
portEND_SWITCHING_ISR() will force a context switch to the newly unblocked
higher priority task.
NOTE: The syntax for forcing a context switch within an ISR varies between
FreeRTOS ports. The portEND_SWITCHING_ISR() macro is provided as part of
the Cortex M3 port layer for this purpose. taskYIELD() must never be called
from an ISR! */
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
donde dice que la función taskyield nunca debe ser llamada desde una ISR. Sin embargo en otro ejemplo de uso de colas en un dspic me encuentro con lo siguiente:
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();
}
}
alguien ha utilizado semáforos en pics o dspics? Este me parece confuso. Cualquier ayuda se las agradezco de antemano
saludos!