This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using event flags from ISR locks up RTX RTOS

I have task waiting on event flags that are triggered from ISR base on TX buffer empty or RX frame received. But I am observing RTOS locking up after a random period ranging from 5 min to few hours. I am not able to figure out why RTOS would be locking up. Using the debugger I can see SysTickTimer not increment, tasks don't switch, no hard faults but ISRs (timers & uarts) triggering.

If I do not receive any data on this uart, no lockups ever. Sending is very busy but data received is very tiny (50-100 bytes/5sec). Uart runs @1MBit baudrate. I have narrow down issue to receiving any data on this uart.

I will appreciate any insight on this issue.
Here is the part of the code:

/**
 *
 */
#ifdef USART2
void USART2_IRQHandler(void)
{
  static uint8_t ChB;

  if(USART_GetITStatus(USART2, USART_IT_TXE) != RESET)
  {
    if (CBUF_Getch(&UsartBOutCBuf, &ChB))
    {
      USART_SendData(USART2, ChB);
    }
    else
    {
      // Uart TX buffer empty, Set event for task to check if endpoints have data to be send.
      isr_evt_set(EVT_FLG_SMPP, TASKID_SMPP);
      USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
    }
  }

  if((USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) ||
     (USART_GetITStatus(USART2, USART_IT_ORE) != RESET))
  {
    ChB = USART_ReceiveData(USART2);
    CBUF_Putch(&UsartBInCBuf, ChB);

    if (1 == SMPP_CheckFrame(ChB))
    {
        // SMPP frame received, Set event for task to read frame, parse and write data to endpoint.
        isr_evt_set(EVT_FLG_SMPP, TASKID_SMPP);
    }
  }
}
#endif


/**
 *
 */
__task void task_smpp(void)
{
    OS_RESULT result;
    uint16_t myTaskId;

    const uint16_t strLen = 64;
    uint8_t str[strLen];
    int8_t byte;
    uint16_t indx;

    myTaskId = TASKID_SMPP;


    for (;;)
    {
        TASKCNT_SMPP++;

        result = os_evt_wait_or (EVT_FLG_SMPP, 1000);

        if (result == OS_R_TMO)
        {
            //postLog ( LogTag_SMPP, "In task_smpp - OS_R_TMO \r\n" );
        }
        else
        {
            // Event received
            //postLog ( LogTag_SMPP, "In task_smpp - OS_R_EVT \r\n" );

            SMPP_WriteFrame();

            SMPP_ReadFrame();

        }
    }
}