FIQ & IRQ mix usage causes kernel to freeze, why?

3 Interrupts enabled, 1 UART to IRQ (serial port), Timer1 to IRQ (to control a flickering LED), and Timer0 to FIQ (to generate an output stepping signal).

first FIQ handler is empty:

void FIQ_HANDLER(void) __fiq
{
   if(FIQSTA & TIMER0)
   {
        T0CLR = 0;
        break;
   }
}

IRQ handler:

void IRQ_HANDLER(void) __irq
{
   if(IRQSTA & TIMER1)
   {
        T1CLR = 0;
        MAKE_LED_FLASH();
        break;
   }
   if(IRQSTA & UART)
   {
        BLAH_BLAH_BLAH();
        break;
   }
}

The code above works just fine, LED flashing, UART responses, and other functions well. But after I added some codes to the FIQ handler, mainly setting a counter(uint16) and let the IO go hign/low:

void FIQ_HANDLER(void) __fiq
    {
       if(FIQSTA & TIMER0)
       {
            if(cts>0)
            {
                IO_BLAH_BLAH_BLAH();
                cts--;
            }
            T0CLR = 0;
            break;
       }
    }

the CPU will lock itself up a few seconds after startup (~2sec), then led stops flashing, UART not responding. Even variable cts is set to 0 at beginning (thus if() cannot be entered).

I first thought it might because of the timer0 set too fast(so that more FIQs stacking together and less being clearing out). So I set timer0 to less frequently. And..alright, seems to be OKAY at startup, LED keeps flashing...but if I send some chars via serial port (UART), the system immediately get locked up again. -_-! WHAT'S WRONG?

Please, if I miss any important information to be written here, just let me know.

Answers


Perhaps one stack is overflowing and corrupting the other. Check that you've initialised the FIQ, IRQ, and other stacks correctly and that you've reserved enough memory for each stack.


Need Your Help

Success function in ajax when using setInterval doesn't work

javascript jquery ajax setinterval

Well I would like to check answer from server every 5 seconds. But my success function inside $.ajax just does not work. Although ajax sends requests and gets response. Time limit is not exceeded s...

SQL changes disappear after VS restart

c# sql-server table

I am learning the basics of C# and SQL interaction, and I have this form:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.