Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


Sending queue from a ISR??

Posted by Thomas Johansen on May 19, 2010

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
// 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
// Wait interrupt
if( pdTRUE == xQueueReceive( xExternal, &byDummy, portMAX_DELAY) ) // Blocks....
// Do stuff here...


RE: Sending queue from a ISR??

Posted by MEdwards on May 19, 2010
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)

RE: Sending queue from a ISR??

Posted by Rohit Grover on May 22, 2010

I'm facing a similar problem using a binary semaphore to synchronize between an ISR and a task. It was suggested to me that I should set the priority of the ISR to be <= configMAX_SYSCALL_PRIORITY; but in my case that did not help. Were you able to resolve your issue? if so, could you please mention how? Thanks.

RE: Sending queue from a ISR??

Posted by woops_ on May 23, 2010
Look for FromISR in Demo\CORTEX_LPC1768_GCC_Rowley\webserver\emac.c for examples.

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists