Karl Olsen wrote:
> --- In lpc2000@yahoogroups.com, "friese99de" <jens.hildebrandt@e...>
> wrote:
>
>>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?
>
>
> The interrupt entry and exit code in gcc 3.2.x and older doesn't
> work. Either upgrade to gcc 3.3.x, where it works, or write the
> entry/exit code yourself.
>
> Regards,
> Karl Olsen
>
>
>
>
>
>
>
Hi Karl,
thanks for the clear answer. I just wanted to be sure that an upgrade of gcc
wouldn't be in vain (at least with respect to my problem).
Regards,
JensMessage
Re: [lpc2000] Re: Interrupt Question
2004-06-15 by Jens Hildebrandt
Attachments
- No local attachments were found for this message.