Forums

AT91SAM7x256 Interrupts

Started by boerrick March 13, 2007
I'm using the AT91SAM7X256 on the AT91SAM7x-EK evaluation board.

I can run my code on the microcontroller (leds, joystick, uart) and
now I try to use interrupts. Has anybody a startup file (in assembler
for GNU compiler) for the AT91SAM7x256 with the use of interrupts??

I've made my own crt.s but it is not working, why, I have no idea!
On Wednesday 14 March 2007 02:49, you wrote:
> I'm using the AT91SAM7X256 on the AT91SAM7x-EK evaluation board.
>
> I can run my code on the microcontroller (leds, joystick, uart) and
> now I try to use interrupts. Has anybody a startup file (in assembler
> for GNU compiler) for the AT91SAM7x256 with the use of interrupts??
http://lejos.svn.sourceforge.net/viewvc/lejos/trunk/nxtvm/platform/nxt/

This is on the Lego NXT using a AT91SAM7S256 running approx 50,000 interrupts
per second.
Charles

>> I can run my code on the microcontroller (leds, joystick, uart) and
>> now I try to use interrupts. Has anybody a startup file (in assembler
>> for GNU compiler) for the AT91SAM7x256 with the use of interrupts??
> http://lejos.svn.sourceforge.net/viewvc/lejos/trunk/nxtvm/platform/nxt/

One hint to make life easier: A single interrupt handler instead of
the AIC method _but_ store into the SMR registers the index into
a table of ISRs.

.section ".text.irq_handler","ax"
.globl irq_handler
.type irq_handler,function
.code 32
irq_handler:
IRQ_PROLOGUE
mvn r1,#-AT91C_BASE_AIC
ldr r0,[r1,#AIC_IVR+1] // acknowledge irq
str r1,[r1,#AIC_IVR+1] // acknowledge irq (protected
// mode)
// void IrqDispatcher(Vectornumber)
bl IrqDispatcher // Can be C-Code !!!

mvn r0,#-AT91C_BASE_AIC
str r0,[r0,#AIC_EOICR+1] // acknowledge interrupt

IRQ_EPILOGUE

void IrqDispatcher(int vn)
{
if ( isr[vn] ){
isr(vn); // Pass Vector to allow a single ISR
// for e.g. UART0 and UART1
} else {
panic("Illegal Interrupt:%d",vn);
}
}

Gain:
- Only one central place to save and restore working registers.
- No need to write wrapper functions for every interrupt.
- Easy way to supervise for unwanted interrupts.

--
42Bastian
42Bastian Schick schrieb:

Ooops,
> void IrqDispatcher(int vn)
> {
> if ( isr[vn] ){
> isr(vn); // Pass Vector to allow a single ISR
> // for e.g. UART0 and UART1

/*should be */ isr[vn](vn);
> } else {
> panic("Illegal Interrupt:%d",vn);
> }
> }
--
42Bastian