"Paul Marcel" <pama19800522@hotmail.com> escribi� en el mensaje
>
> OK. It seems that I CAN have an interrupt routine in C with this
> version of the gnu arm compiler. But I am still trying to get
> interrupts to work with this code. The main loop runs (LED1 flashes),
> but the C interrupt function never gets called. I'm using a nohau jtag
> interface with Seehau to load the code. I have set breakpoints
> inside the C interrupt and also at the interrupt vector location, but
> neither one happens. This is for the eb40a board.
>
Some time ago I had trouble with the interrupts and the eb55.
I used GCC 3.3.1 and GDB, and I never got the ' __attribute__
interrupt' thing to work.
Eventually I got it working using an assembly entry routine which in turn
called the C function 'void timer1_interrupt_handler (void)'.
I am including the assembler routine just in case you feel like giving it
a try. It is ATMEL sample code, modified to get it assembled with GNU.
HTH
Josep Duran
/*;-------------------------------------------------------------------------
----------------------------------
; The software is delivered "AS IS" without warranty or condition of any
kind, either express, implied or statutory.
; This includes without limitation any warranty or condition with respect to
merchantability or fitness for any particular purpose, or
; against the ;infringements of intellectual property rights of others.
;---------------------------------------------------------------------------
--------------------------------
;- File source : irq_timer.s
;- Object : Assembler timer Interrupt Handler
;- Author : AT91 Application Group
;---------------------------------------------------------------------------
--------------------------------
;---------------------------------------------------------------------------
--------------------------------
;- Area Definition
;---------------------------------------------------------------------------
--------------------------------
*/
.section code /* ,"r" segurament no cal */
/*.interwork ************* */
.equ ARM_MODE_USER,0x10
.equ AIC_BASE, 0xFFFFF000
.equ AIC_IVR, 0x100
.equ AIC_EOICR,0x130
/* ARM Core Mode and Status Bits */
.equ ARM_MODE_IRQ, 0x12
.equ ARM_MODE_SYS, 0x1F
.equ I_BIT, 0x80
.MACRO IRQ_ENTRY reg
/* Adjust and save LR_irq in IRQ stack */
sub r14, r14, #4
stmfd sp!, {r14}
/* Write in the IVR to support Protect Mode */
/* No effect in Normal Mode */
/* De-assert the NIRQ and clear the source in Protect Mode */
ldr r14, =AIC_BASE
str r14, [r14, #AIC_IVR]
/* Save SPSR and r0 in IRQ stack */
mrs r14, SPSR
stmfd sp!, {r0, r14}
/* Enable Interrupt and Switch in SYS Mode */
mrs r0, CPSR
bic r0, r0, #I_BIT
orr r0, r0, #ARM_MODE_SYS
msr CPSR_c, r0
/* Save scratch/used registers and LR in User Stack */
.ifndef reg
stmfd sp!, { r1-r3, r12, r14}
.ELSE
stmfd sp!, { r1-r3, \reg, r12, r14}
.ENDIF
.ENDM
.MACRO IRQ_EXIT reg
/* Restore scratch/used registers and LR from User Stack */
.ifndef reg
ldmia sp!, { r1-r3, r12, r14}
.ELSE
ldmia sp!, { r1-r3, \reg, r12, r14}
.ENDIF
/* Disable Interrupt and switch back in IRQ mode */
mrs r0, CPSR
bic r0, r0, #ARM_MODE_SYS
orr r0, r0, #I_BIT | ARM_MODE_IRQ
msr CPSR_c, r0
/* Mark the End of Interrupt on the AIC */
ldr r0, =AIC_BASE
str r0, [r0, #AIC_EOICR]
/* Restore SPSR_irq and r0 from IRQ stack */
ldmia sp!, {r0, r14}
msr SPSR_cxsf, r14
/* Restore adjusted LR_irq from IRQ stack directly in the PC */
ldmia sp!, {pc}^
.ENDM
/*
;---------------------------------------------------------------------------
--------------------------------
;- Function : timer1_asm_irq_handler
;- Treatments : Timer 1 interrupt handler.
;- Called Functions : timer1_c_irq_handler
;- Called Macros : IRQ_ENTRY, IRQ_EXIT
;---------------------------------------------------------------------------
--------------------------------
*/
.global timer1_asm_irq_handler /* .IMPORT */
.extern timer1_c_irq_handler /* .EXPORT */
timer1_asm_irq_handler:
/* Manage Exception Entry */
IRQ_ENTRY
/* Call the timer Interrupt C handler */
ldr r1, =timer1_c_irq_handler
mov r14, pc
bx r1
/* Manage Exception Exit */
IRQ_EXIT
/*
**;-------------------------------------------------------------------------
-----
*/
.GLOBAL habili
habili:
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
sub fp, ip, #4
mrs R0, CPSR
bic r0,r0,#0x80
msr CPSR, R0
ldmfd sp, {fp, sp, pc}
.END