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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top