Im using RTOS 5.1.2, KEIL and a LPC2478 MCU. On a external interrupt I do have to invoke a task. The task is waiting on a massage with a xQueueReceive(). The message is send from the ISR with the xQueueSendToFrontFromISR() function. But the waiting task never gets invoked. The xQueueSendToFrontFromISR() returns pdPASS. See the code used below. I know the task in running ok. Setting a timeout in the xQueueReceive() makes the function return on the expected time. The first time I call xQueueReceive(), after a reset, the function right away with the status pdTRUE. But a message was never send? Next time the xQueueReceive() is called the function blocks. Any idea why? Must I use another receive function when using xQueueSendToFrontFromISR???
Is there a better way of getting a hardware interrupt to a task?
void ExternalInterruptInit(void)
{
// Creating queue
static xQueueHandle xExternal;
xExternal= xQueueCreate( 1, sizeof(portCHAR) );
// Init interrupt, GPIO etc.
....
...
}
/ ISR for external interrupt - Key pressed
void KeyPressedISRHandler (void)
{
portBASE_TYPE status;
// Key state
BYTE byKeyDown = 0;
// Token
portBASE_TYPE xHigherPriorityTaskWoken;
// Send event
byKeyDown = 1;
status = xQueueSendToFrontFromISR( xExternal, &byKeyDown, &xHigherPriorityTaskWoken );
// Clear interrupt
EXTINT = EINT0;
// Acknowledge interrupt
VICVectAddr = 0;
// Did sending to the queue unblock a higher priority task?
portEXIT_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
// Task for external interrupt events
static void ExternalIntTask(void *pvParameters)
{
// Forever
while(TRUE)
{
// Wait interrupt
if( pdTRUE == xQueueReceive( xExternal, &byDummy, portMAX_DELAY) ) // Blocks....
{
// Do stuff here...
.....
.....
}
}
}
/Thomas