xQueueReceive Blocks application on LPC2129

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.

xQueueReceive Blocks application on LPC2129

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 Queuen”);
//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=%cn”, 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;
        SERIAL_RECV_QUEUE recvdMsg;         portBASE_TYPE xHigherPriorityTaskWoken;
        xHigherPriorityTaskWoken = pdFALSE;         recvdChar = U0RBR;
        recvdChar = ‘’;         recvdMsg.cmd = recvdChar;         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 : %sn”, recvdChar);
        VICVectAddr = 0; /* Acknowledge Interrupt */
}
################################################################################33

xQueueReceive Blocks application on LPC2129

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.

xQueueReceive Blocks application on LPC2129

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 */
} ############################/

xQueueReceive Blocks application on LPC2129

looks like problem with uart configuration and interrupt handler.. looking into it