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

xQueueReceive Blocks application on LPC2129

Posted by GCD on March 22, 2013
i have an application where, a message is posted from an ISR using call "xQueueSendToBackFromISR" which is done successfully. but a task which is waiting on queue to receive the message posted from ISR, blocks the whole application once it receives the message posted from ISR and the application hangs.

RE: xQueueReceive Blocks application on LPC2129

Posted by GCD on March 22, 2013
following code shows the creation of task & queue, posting and receiving of queue.

Task waiting on queue: serialRecvTask
Isr Posting message : UART0_Recv_Interrupt_Handler
Message Queue created: serialRecvQueue





************************************
typedef struct _serialRecvQueue
{
unsigned char cmd;

}SERIAL_RECV_QUEUE;
*************************************


/////##### Task 'serialRecvTask' and queue 'serialRecvQueue' are created here in main function.

################################ Main function creating Task and queue #########################################
int main(void)
{
APP_SHARED_DATA appSharedData;
int i;

initTarget();

//xTaskCreate(ledTask, "NAME", configMINIMAL_STACK_SIZE, (void *)&appSharedData, mainLED_TASK_PRIORITY + 5, ( xTaskHandle * ) NULL );
// xTaskCreate(serialOutTask, "NAME", configMINIMAL_STACK_SIZE, (void *)&appSharedData, mainCHECK_TASK_PRIORITY, ( xTaskHandle * ) NULL );
// xTaskCreate(keyTask, "NAME", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY + 7, ( xTaskHandle * ) NULL );
// xTaskCreate(adcTask, "NAME", configMINIMAL_STACK_SIZE, (void *)&appSharedData, mainCHECK_TASK_PRIORITY + 6, ( xTaskHandle * ) NULL );
// xTaskCreate(dummyTask, "NAME", configMINIMAL_STACK_SIZE, (void *)&appSharedData, mainCHECK_TASK_PRIORITY + 4, ( xTaskHandle * ) NULL );
xTaskCreate(serialRecvTask, "NAME", configMINIMAL_STACK_SIZE, (void *)&appSharedData, mainCHECK_TASK_PRIORITY + 8, ( xTaskHandle * ) NULL );
// xTaskCreate(canMsgProcessTask, "NAME", configMINIMAL_STACK_SIZE, (void *)&appSharedData, mainCHECK_TASK_PRIORITY + 9, ( xTaskHandle * ) NULL );
// xTaskCreate(canControlTask, "NAME", configMINIMAL_STACK_SIZE, (void *)&appSharedData, mainCHECK_TASK_PRIORITY + 8, ( xTaskHandle * ) NULL );

/* Create Queue for Serial Input */
serialRecvQueue = xQueueCreate(5, sizeof(SERIAL_RECV_QUEUE));
if(serialRecvQueue == 0)
{
putstr("Could NOT create serialRecvQueue");
putchar('\n');
}
}




//#####################################################################################

################ Task waiting on Queue #####################################3

void serialRecvTask(void* pvParameters)
{
SERIAL_RECV_QUEUE recvSerialCmd;
unsigned char levelSensorVal = 0;
unsigned char resistanceVal = 0;
pvParameters = pvParameters;

while(1)
{
printf("Serial Recv Task: Waiting on Queue\n");
//if(xQueueReceive(serialRecvQueue, (void *)&recvSerialCmd, portMAX_DELAY))//If can be taken off as task gets blocked
if(xQueueReceive(serialRecvQueue, (void *)&recvSerialCmd, 1000))//If can be taken off as task gets blocked
{
printf("Serial Recv Task: Received Msg=%c\n", recvSerialCmd.cmd);
#if 0
switch(recvSerialCmd.cmd)
{
case 0x31:{
printf("%c%c", recvSerialCmd.cmd, levelSensorVal++);
levelSensorVal = levelSensorVal % 253;
break;
}
case 0x32:{
printf("%c%c", recvSerialCmd.cmd, resistanceVal++);
resistanceVal = resistanceVal % 253;
break;
}
default:{
printf("%c%c", recvSerialCmd.cmd, 0xFF);
break;
}

}
#endif
}

vTaskDelay(10); // May not be required
}

}




####################################################################################



//################ Interrupt posting Queue Message ##########################/
void UART0_Recv_Interrupt_Handler(void){

unsigned char recvdChar[2];
SERIAL_RECV_QUEUE recvdMsg;

portBASE_TYPE xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;

recvdChar[0] = U0RBR;
recvdChar[1] = '\0';

recvdMsg.cmd = recvdChar[0];

if(serialRecvQueue != 0)
{
//if(xQueueSendToBackFromISR(serialRecvQueue, (void *)&recvdMsg, &xHigherPriorityTaskWoken) != pdPASS)
if(xQueueSendToBackFromISR(serialRecvQueue, (void *)&recvdMsg, pdFALSE) != pdPASS)
{
putstr("UART0 ISR: Failed to send Message");
putchar('\n');
}
else
{
// putstr("UART0 ISR: Message Queued Successfully");
// putchar('\n');
}
}
else
{
putstr("UART0 ISR: Not Valid Queue");
putchar('\n');

}
printf("Received String : %s\n", recvdChar);
VICVectAddr = 0; /* Acknowledge Interrupt */
}
################################################################################33




RE: xQueueReceive Blocks application on LPC2129

Posted by Richard on March 22, 2013
Which version of FreeRTOS are you using (it makes a difference as to whether you can pass false as the last parameter to the xQueueSendFromISR() function).

What happens if you take all the calls to printf() out?

Are putstr() and putchar() safe to call from an interrupt?

Is the interrupt being cleared in the UART (it might happen automatically, I can see you clear it in the VIC).

Can you post the wrapper code from which UART0_Recv_Interrupt_Handler() is called.

Regards.

RE: xQueueReceive Blocks application on LPC2129

Posted by GCD on March 22, 2013


I am using version 7.0, messaging is working fine with other things for example, posting & receiving messages between tasks, infact even message posted from an FIQ ISR is being received clearly with other task which i am using to receive switch input and a task..

removing prints/putstr/putchar.. did not make any difference(this is just a function), commenting out other queues created for different purpose just made "xQueueReceive(serialRecvQueue, (void *)&recvSerialCmd, portMAX_DELAY);" to respond occationaly but still freezing the application.

with LPC2129, "VICVectAddr = 0; /* Acknowledge Interrupt */" is normally what is done to clear the interrupt. took an example from Keil.


"UART0_Recv_Interrupt_Handler()" is registered while initializing the serial port as below.

/##########################
void init_serial (void) { /* Initialize Serial Interface */

volatile char dummy;

PINSEL0 = 0x00050005; /* Enable RxD1 and TxD1 */

/*UART1 */
U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
// U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
U1DLL = 0XC2;
U1LCR = 0x03; /* DLAB = 0 */

//RX Interrupt Enable
/*---------------------------------------INTERRUPT HANDLER-----------------------*/
VICVectAddr5 = (unsigned long)UART0_Recv_Interrupt_Handler;
/*----------------------------------------------------------------------------------------------*/
VICVectCntl5 = 0x20 | 6; /* UART0 Interrupt */
VICIntEnable = 1 << 6; /* Enable UART1 Interrupt */



/* UART0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
// U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
U0DLL = 0XC2;
U0LCR = 0x03; /* DLAB = 0 */

/*-------------------------------------- I am doubting this statement but not sure if this is the cause--------------*/

dummy = U0IIR; /* Read IrqID - Required to Get Interrupts Started */
/*---------------------------------------------------------------------------------------------------------------------------------------*/
U0IER = 0x01; /* Enable UART1 RX and THRE Interrupts */
}


############################/

RE: xQueueReceive Blocks application on LPC2129

Posted by GCD on March 22, 2013
looks like problem with uart configuration and interrupt handler.. looking into it


[ 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