EmbeddedRelated.com
Forums

Interrupt problem with LPC2138

Started by bmueller38 September 14, 2006
Hi everybody,

I am trying to use Timer0 Interrupts, but it doesn't really work and I
have no idea why.

The first thing that I don't understand is that the board behaves
differently after "hard reset" (power off - power on) and when I let
it run in my debugger.

In the first case, interrupt seemed to work while in the second case
they did not. I don't know how, but I got this problem fixed. Maybe
someone can explain the difference?

Now the thing is that the controller goes through "undefined mode"
after calling enableIRQ(). In hard-reset case only sometimes and just
once, in debug-run case it sticks there.

My interruptroutine looks as follows:

void T0ISR (void)
{
disableIRQ();
write_uart1("Interrupt!");
T0IR = 0x1;
VICVectAddr = 0;
enableIRQ();
}

with:

#define IRQ_MASK 0x00000080
unsigned enableIRQ (void)
{
unsigned _cpsr;
write_uart1("enable");
_cpsr = __get_cpsr();
__set_cpsr(_cpsr & ~IRQ_MASK);
return _cpsr;
}

To me it seems as if the controller doesn't know where to continue
after T0ISR() or enableIRQ().

Migth there be something wrong in my startup code? Any other
suggestions? Please help.
Thanks.

bjoern

An Engineer's Guide to the LPC2100 Series

> Now the thing is that the controller goes through "undefined mode"
> after calling enableIRQ(). In hard-reset case only sometimes and just
> once, in debug-run case it sticks there.
>
> My interruptroutine looks as follows:
>
> void T0ISR (void)
> {
> disableIRQ();
> write_uart1("Interrupt!");
> T0IR = 0x1;
> VICVectAddr = 0;
> enableIRQ();
> }
>
> with:
>
> #define IRQ_MASK 0x00000080
> unsigned enableIRQ (void)
> {
> unsigned _cpsr;
> write_uart1("enable");
> _cpsr = __get_cpsr();
> __set_cpsr(_cpsr & ~IRQ_MASK);
> return _cpsr;
> }
>
> To me it seems as if the controller doesn't know where to continue
> after T0ISR() or enableIRQ().

I found out that the processor at least sometimes goes through
prefetch and data abort routines after executing T0ISR(). To me it
seems as if the return address got lost? Or might the use of UART1 for
debugging cause problems? Please help.

Thanks
bjoern