I'm trying to get a very simple timer interrupt working in C on Atmel's EB40A board. The processor is an Atmel AT91R40008. I'm using the gnu tools from codesourcery (arm-none-elf-gcc etc). I have some non-interrupt samples working. The interrupt is not working. LED1 (the main loop LED) blinks, but the timer LED doesn't blink. I found this sample on Atmel's web site but that loaded timer1_asm_irq_handler into AIC_SVR5. I'd LIKE to load it with "time1_c_irq_handler" instead. Could someone tell me if I can do that and how to get this simple example working? Here's a link to the files: www.toadhaul.org/arm.php Paul
Simple ARM timer interrupt question
Started by ●November 16, 2004
Reply by ●November 16, 20042004-11-16
Only thing I can think of right now is to look at the assembly language that the compiler generates for the interrupt routine. Make sure it conforms to an interrupt service routine. Most CPUs have a seperate return instruction for regular subroutines and for interrupt service routines. You didn't mention any compile or link errors/warnings so I assume it all goes together ok.
Reply by ●November 16, 20042004-11-16
> sample on Atmel's web site but that loaded timer1_asm_irq_handler into > AIC_SVR5. I'd LIKE to load it with "time1_c_irq_handler" instead. > Could someone tell me if I can do that and how to get this simpleYou can't vector the interrupt direct to C. You need an asm reflector shim.
Reply by ●November 17, 20042004-11-17
On 16 Nov 2004 17:10:59 -0800, larwe@larwe.com (Lewin A.R.W. Edwards) wrote:>> sample on Atmel's web site but that loaded timer1_asm_irq_handler into >> AIC_SVR5. I'd LIKE to load it with "time1_c_irq_handler" instead. >> Could someone tell me if I can do that and how to get this simple > >You can't vector the interrupt direct to C. You need an asm reflector shim.Oh. I didn't know that. Do you have an example of how the asm reflector should be? Paul
Reply by ●November 17, 20042004-11-17
"Lewin A.R.W. Edwards" <larwe@larwe.com> wrote in message news:608b6569.0411161710.2f2299bc@posting.google.com...> > sample on Atmel's web site but that loaded timer1_asm_irq_handler into > > AIC_SVR5. I'd LIKE to load it with "time1_c_irq_handler" instead. > > Could someone tell me if I can do that and how to get this simple > > You can't vector the interrupt direct to C. You need an asm reflectorshim. well I have an ARM timer interrupt written entirely in C that uses the GCC extension void __attribute__((interrupt("IRQ"))) SYS_kbd_irq_handler(void) { ... } I then stuff the function pointer into the VIC works fine for me. -- Peter.Dickerson (at)...
Reply by ●November 17, 20042004-11-17
On Wed, 17 Nov 2004 14:24:32 GMT, "Peter Dickerson" <first{dot}surname@ukonline.co.uk> wrote:>"Lewin A.R.W. Edwards" <larwe@larwe.com> wrote in message >news:608b6569.0411161710.2f2299bc@posting.google.com... >> > sample on Atmel's web site but that loaded timer1_asm_irq_handler into >> > AIC_SVR5. I'd LIKE to load it with "time1_c_irq_handler" instead. >> > Could someone tell me if I can do that and how to get this simple >> >> You can't vector the interrupt direct to C. You need an asm reflector >shim. > >well I have an ARM timer interrupt written entirely in C that uses the GCC >extension > >void __attribute__((interrupt("IRQ"))) SYS_kbd_irq_handler(void) >{ > ... >} > >I then stuff the function pointer into the VIC > >works fine for me.I added a "shim" in boot.asm and tried that by loading the AIC_SVR5 register with the assembly routine. I had to modify the assembly code to get it to assemble with arm-none-elf-as. But still no interrupts. It did not even break in the assembly routine. I switcheck back to a strictly C interrupt changing the function declartion to the form of your Sys_kbd_irq_handler, but still no interrupts. The program is running because the main loop is blinking the mainline led. It seems that I need to do something else to enable interrupts. Any ideas? The current state of the test program is at www.toadhaul.org/arm.php Paul
Reply by ●November 17, 20042004-11-17
> well I have an ARM timer interrupt written entirely in C that uses the GCC > extensionWhat GCC version are you using?
Reply by ●November 18, 20042004-11-18
"Peter Dickerson" <first{dot}surname@ukonline.co.uk> wrote in message news:AaJmd.71$ze1.35@newsfe2-win.ntli.net...> "Lewin A.R.W. Edwards" <larwe@larwe.com> wrote in message > news:608b6569.0411161710.2f2299bc@posting.google.com... > > > sample on Atmel's web site but that loaded timer1_asm_irq_handler into > > > AIC_SVR5. I'd LIKE to load it with "time1_c_irq_handler" instead. > > > Could someone tell me if I can do that and how to get this simple > > > > You can't vector the interrupt direct to C. You need an asm reflector > shim.Never heard of an asm reflector shim. GCC allows the interrupt to be written in C by using the __attribute__ extension. Search for __attribute__ on http://www.freertos.org/portlpc2106.html. The FreeRTOS source code has examples for the serial port and a timer interrupt - but for a Philips not an Atmel.
Reply by ●November 18, 20042004-11-18
Paul Marcel <pama19800522@hotmail.com> wrote in message news:<2otmp01fpma8jf3gne9b853d9jshvadds1@4ax.com>...> On Wed, 17 Nov 2004 14:24:32 GMT, "Peter Dickerson" > <first{dot}surname@ukonline.co.uk> wrote: > > >"Lewin A.R.W. Edwards" <larwe@larwe.com> wrote in message > >news:608b6569.0411161710.2f2299bc@posting.google.com... > > > > You can't vector the interrupt direct to C. You need an asm reflector > > shim.Would that be the same as a veneer? [snip blah blah]> It seems that I need to do something else to enable interrupts. Any > ideas?At some point in the output code is there something like MRS r0, CPSR BIC r0, r0, #I_BIT MSR CPSR_cxsf, r0 present? ARM's reset with global interrupts disabled, Sprow.
Reply by ●November 18, 20042004-11-18
> Never heard of an asm reflector shim. > > GCC allows the interrupt to be written in C by using the __attribute__ > extension.At the time I last wrote an ISR on an ARM platform - which was probably at least 18 months ago - the GCC documentation said explicitly that interrupts are not part of C, and are therefore not directly supported. It was necessary to write a little snippet of ARM assembler like: fiq_handler: stmdb r13!, {r0-r7, r12} ldr r12, irqvector bx r12 ldmia r13!, {r0-r7, r12} subs pc, r14, #4 irqvector: .word c_fiq_handler where c_fiq_handler is the C routine containing the actual ISR code.