Yahoo Groups archive

Lpc2000

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

Message

Re: Interrupt works in Keil simulator but not in target

2003-12-11 by lpc2100

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
    ldmfd   sp!, { r0-r3,r12,lr }

/* Resume interrupted execution flow */
    subs    pc, lr, #0x4

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.