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




Loading

xQueueSendBackFromISR fails after many hours

Posted by belmondo on February 1, 2013
I am having an issue with xQueueSendBackFromISR. I use it inside a UART interrupt routine to send a message to another task to state that a line is ready to be read. It works for hours and suddenly for any reason, the xQueueSendBackFromISR fails. It does not return pdPASS. The queue is not full. I even reset it when the problem occur but it does not seem to help. The xQueueSendBackFromISR never seem to respond back and always fails thereafter.

Does anyone know what the issue could be ?

RE: xQueueSendBackFromISR fails after many hours

Posted by belmondo on February 1, 2013
Here is the Interrupt Code



void USART1_IRQHandler(void)
{
uint8_t ch;
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

int num;
char line[80];

unsigned int cmd;
static int count = 0;
ErrorStatus err;

// Receive interrupt
if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
ch=(uint8_t)USART_ReceiveData(USART1);
err = BufferPut(&U1Rx, ch);

if ( err == ERROR ) {
cmd = 5;
xQueueSendToBackFromISR(uartQueue,&cmd,&xHigherPriorityTaskWoken);
}

else if (ch == '\n') {
trace_set(7);
count = 0;
cmd = 1;
num = uxQueueMessagesWaitingFromISR(uartQueue);
if ( xQueueSendToBackFromISR(uartQueue,&cmd,&xHigherPriorityTaskWoken) != pdPASS ) {
sprintf(line,"Uart Queue Send Error: %d in the queue.................",num);
xprintln(line);
}
trace_reset(7);
}

else if ((count == 0) && (ch == '>') ){
cmd = 2;
xQueueSendToBackFromISR(uartQueue,&cmd,&xHigherPriorityTaskWoken);
}

else {
if (count >= 2000) {
cmd = 6;
xQueueSendToBackFromISR(uartQueue,&cmd,&xHigherPriorityTaskWoken);
count = 0;
} else {
count++;
}
}
}

// Other Error Flags
if (USART_GetFlagStatus(USART1, USART_FLAG_ERRORS) != RESET) {
USART_ReceiveData(USART1); // Clear Error
xprintln("Uart Error.................");
}

portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);

}



RE: xQueueSendBackFromISR fails after many hours

Posted by MEdwards on February 1, 2013
When it stops working can you put a break point in the code and step into the function to see what it is doing?
Is your interrupt stack large enough for the line[80] array and to call sprintf() which often uses a lot of stack space?
Can xprintln be called from an interrupt?


RE: xQueueSendBackFromISR fails after many hours

Posted by Richard Damon on February 2, 2013
A couple of issues that might cause this sort of error.

1) Stack corruption, this ISR uses a LOT of stack for an ISR, since it allocates an 80 byte array. Many ports use the current tasks stack for the ISR, so in this case you need this much extra room in every task's stack. If one doesn't have enough, then when you get "lucky" enough to interrupt while that task is active, problems arise.

2) Make very sure that you have interrupt priorities set properly. Most ports only allow ISRs of certain priorities to call FreeRTOS APIs, and an interrupt at a higher level than this can cause corruption that could cause this.


[ 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