I have problems sending messages from a ISR to a task.
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?
// Creating queue
static xQueueHandle xExternal;
xExternal= xQueueCreate( 1, sizeof(portCHAR) );
// Init interrupt, GPIO etc.
/ ISR for external interrupt - Key pressed
void KeyPressedISRHandler (void)
// Key state
BYTE byKeyDown = 0;
// 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)
// Wait interrupt
if( pdTRUE == xQueueReceive( xExternal, &byDummy, portMAX_DELAY) ) // Blocks....
// Do stuff here...
The code is hard to read because the formatting has been lost. It is possible to post using the 'codify text' tags to keep the indents.
ExternalInterruptInit() is creating a queue, but xExternal is static so cannot be accessed from outside of the function. I'm not sure how you access it in the interrupt handler.
xHigherPriorityTaskWoken should be initialised to 0 before it is used.
Other than that I cannot see anything wrong.
(just noticed the closing so don't know where the formatting went)
Look for FromISR in Demo\CORTEX_LPC1768_GCC_Rowley\webserver\emac.c for examples.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.