Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2100] Re: Interrupt works in Keil simulator but not in target

2004-02-11 by Soeren Gust

I know that the original message is quite old, but I just spent several
hours trying to get it to work and finally found that the problem is a
missing closing comment. So the restoring ldmfd instruction never gets
executed, the calling address in lr still points inside the handler
which gives a nice endless loop. It will also fill up the interrupt
stack.

I also have a hint to other beginners on ARM processors: they have
several stacks, you need to initialize all you want to use. There is an
example on how to do this for the IRQ and FIQ stack in the application
note AN10254 on the Philips web site.

On Thu, Dec 11, 2003 at 03:39:18AM -0000, somebody wrote:
> Replace your irq handler with the following code.
> This example uses VIC. I hope you can figure out how to program the 
> VIC. Do NOT use the gnu "interrupt" keyword in your C function. You 
> also need to program the VIC address registers with the appropriate C 
> function handler addresses.
> 
> irq_handler:
> 
> /* save return address and work regs on stack */
> /* save r0-r4,lr,r12 on stack remaining regs */
> /* are saved by the c function if used */
> 
>     stmfd   sp!, { r0-r3,r12,lr }
> 
> /* use r1 to save spsr_irq */
> 
>     mrs     r1, spsr
> 
> /* save r1 again as per ATPCS r0-r4 & r12 are not saved */
> /* by the called function */
> 
>     stmfd     sp!,{r1}         
> 
> /* setup link register so that the normal c function */
> /* which is used as an isr returns to ldmfd sp!,{r1} instruction */
> 
>     add     lr,pc,#0x4         
> 
> /* Read the ISR address from the VIC */
> 
>     ldr r0, =0xfffff030        
>     ldr pc,[r0]
> 
> /* Restore spsr_irq */
>     ldmfd sp!,{r1}
>     msr     spsr_cxsf, r1       
> 
> /* Restore remaining registers

put a */ there ------------------^

>     ldmfd   sp!, { r0-r3,r12,lr }
> 
> /* Resume interrupted execution flow */
>     subs    pc, lr, #0x4

Soeren Gust

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.