--- In lpc2000@yahoogroups.com, "digtalfreak" <digitalfreak@n...>
wrote:
> I solved the Problem, it was a wrong startupcode that blocked the
> modus change.
>
> But now I have the problem that the interrupt causes an exaption, I
> think. The ISR is never reached and if I stop the programm the pc is
> pointing to 0x7fffe2ae, this must be somewhere in the RAM-mapped
> bootloader, how could this happen and how could I fix this?
>
> --- In lpc2000@yahoogroups.com, "digtalfreak" <digitalfreak@n...>
wrote:
> > I am using gcc and insignt and have problems using Interrupts.
> > I'm trying to use Timer0 to generate a Interrupt, similar to the
Keil
> > example "blinky", but the interupt is never generatet because the
cpsr
> > register seems to be allways switched back to 0xd0. Looks like my
"msr
> > cpsr_c, #0x10" is ingored or overwriten.
> > btw... the precompiled keil example works with insight, timer is
> > running and genarating interrupts.
> >
> > please help...
Hi,
I just came across this group because I have a problem similar to that
of the OP. Did you find a solution meanwhile?
I'm using gcc 3.2.1 under cygwin and tried to build the blinky_irq
example for a LPC2106. Since it didn't work I stripped the program
down to a bare endless loop in main() and a timer ISR that toggles a
LED an GPIO24. After approx. 3min. the LED stops toggling and I get an
Abort exception. A look at the disassembled code showed that gcc is
messing up the stack pointer in IRQ mode, losing some words every time
the ISR is invoked.
The code looks the following way:
00000278 <tc0>:
278: e52dc004 str ip, [sp, -#4]!
27c: e1a0c00d mov ip, sp
280: e24ee004 sub lr, lr, #4 ; 0x4
284: e92dd80c stmdb sp!, {r2, r3, fp, ip, lr, pc}
288: e24cb004 sub fp, ip, #4 ; 0x4
28c: e3a0320e mov r3, #-536870912 ; 0xe0000000
290: e283390a add r3, r3, #163840 ; 0x28000
294: e5933000 ldr r3, [r3]
... some load and store operations on GPIO registers with r2, r3 ...
2e0: e3a02000 mov r2, #0 ; 0x0
2e4: e5832000 str r2, [r3]
2e8: e95b980c ldmdb fp, {r2, r3, fp, ip, pc}^
As you can see, in the beginning registers are saved on the stack thus
decrementing sp. BTW, the way ip is saved in the beginning is
pointless since ip is not restored from that location upon ISR exit.
At the end, registers are restored from stack using fp as base
pointer. The pc is loaded with the adjusted return address and
simultaneously cpsr is restored from spsr_irq. Sp however is not
restored so that at ISR exit sp is seven words lower than at ISR
entry.
Either I missed some point when building the program (e.g. forgot
certain gcc options) or gcc 3.2.1 is buggy here.
Options I use are "-mcpu=arm7tdmi -gstabs" for the assembly of
startup.s and "-c -g -I. -mcpu=arm7tdmi" for compiling of C-source
files. Linker options are "-T Flash.ld -nostartfiles -Lgcc -L.", where
Flash.ld is the linker script supplied with Keil's blinky_irq example
adjusted to the actual Flash and RAM sizes of the LPC2106.
Has anybody else in the group encountered similar problems and if so,
have you found a solution?
TIA,
Jens