LPC2368 crashing after X uart interrupts

First of all, I’m using LPC2368, FreeRTOS 5.4.2, last yagarto version (Binutils-2.19., Newlib-1.17.0, GCC-4.3.3, GDB-6.8.50-20080308, Insight-6.8.50-20080308) and Windows XP.

I’ve compiled LPC2368 example only flashing the leds and everything have been ok. Nevertheless, I’m trying to use an interrupt driven uart, but with no success.

The problem is that after a well defined number of UART interrupts, the system crashes. That’s a well defined number.

It seems to be a stack overflow problem, but changes in IRQ stack in boot.s doesn’t change anything. However, if I change optimization, then the number of interrupts before the crash changes.

It is related to UART interrupt since if I disable UART interrupt, I can send characters over serial with no problems.

I’ve uploaded the code to http://www.4shared.com/file/125067940/a … stion.html .

Any suggestion will be well received. :wink:

Thanks in advance,

Eduardo Garcia

Not much help, but that UART interrupt driver in freeRTOS, running on an LPC2106 with the latest FreeRTOS works fine. Indeed, I’ve created a dual-UART version. I’m using IAR’s compiler.

Wondering what this change is for

VICVectCntl6 = 0x0F;

as compared to the original line of code.

Does GCC generate the correct ISR preamble/postamble code that FreeRTOS assumes (registers used, etc.)?

Here’s the code I use for interrupt-driven UART receive with a circular buffer (LPC2148):

//------------------------ UART0 ISR ------------------------//
static void
uart0ISR(void)
{
  /* Read IIR to clear interrupt and find out the cause */
  unsigned iir = U0IIR;

  /* Handle UART0 interrupt */
  switch ((iir >> 1) & 0x7)
    {
      case 1:
        /* THRE interrupt */
        break;
      case 2:
        /* RDA interrupt */
        do
          {
          uint16_t temp;

          // calc next insert index & store character
          temp = (uart0_rx_insert_idx + 1) % UART0_RX_BUFFER_SIZE;
          uart0_rx_buffer[uart0_rx_insert_idx] = U0RBR;

          // check for more room in queue
          if (temp != uart0_rx_extract_idx)
            uart0_rx_insert_idx = temp; // update insert index
          }
        while (U0LSR & 0x01);

        break;
      case 3:
        /* RLS interrupt */
        break;
      case 6:
        /* CTI interrupt */
        break;
   }
}

Leon

Hi stevech,

Thanks for your attention!

Yes, I already have done a code to LPC2294 with FreeRTOS and GCC (other versions) based on LPC2106 example and it’s is working fine.

I will try come back to the other version of Yagarto… maybe it can give me some information or interesting results.

I’m sorry but how can I see if GCC generate the correct ISR preamble/postamble code that FreeRTOS assumes? :frowning:

Hi leon_heller,

Thanks for your help. But I think that my problem is related to FreeRTOS… Don’t you think? :?

I’ve just discovered and fixed the problem.

There as a mistake in uart wrapper function prototype, so that, the real function was not a naked function. Each time that the uart_wrap function was called, the stack wasn’t recovered.

Once I declared uart wrapper function correctly, everything starts working fine.

Thanks all!

eduardogarcia-

It is great that you were able to find a solution. As far as I can tell, I have the same problem with some of my code.

Unfortunately, I’m not sure I understand enough to fix it. Could you expand on your answer? Providing the correct uart wrapping code would be even better.

Thanks

david