FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2010 Threads]
Hallo
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?
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
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.