Simple boot-up code for an Atmel A91

I'm still having an extremely hard time getting IRQ interrupts of any sort to work on my AT91R40008. Does anyone have a simple boot.s that sets up all the stacks for IRQ interrupts and then can branch to C functions? I am not using any debug monitors like Angel. I am not using any pre-canned libraries (like Atmel's) I am using gcc-3.2, and I am trying to implement my interrupt handlers in C also.

Here is exactly what I'm trying to do:

- I'm not bothering with running from flash at the moment. Currently I"m locating my code at 0x00, manually initiating a REMAP through my JTAG interface and then loading the code (so it should be all loaded into RAM)

- I have a small test program which toggles PIO pins every TIMER0 overflow interrupt.

The problems I've been having:

- The pin will go high (suggesting the reception of 1 interrupt) and then stay high - halting the processor results in the PC being at either Data Abort or Program Abort in the vector table (the first weirdness).

- If I issue a RESET command, and then execute the program again (w/o powering down the chip), the program runs fine and just loops infinitely on my while(1) { } at the end of main, but there is no pin toggling at all (suggesting no reception of interrupts)

I have been communicating with Tauno somewhat and he has been a great help so far.

Here's what I understand I must do (but may not be implementing it correctly): Setup the IRQ, SVC, and SYS stacks. Enable Timer interrupts in the TC registers and the AIC (pretty sure I have this correct). Setup interrupt vector in the AIC (pretty sure I also have this correct). Writing to AIC_EOICR at the end of the interrupt handler (I have this correct).

Reply to
James Laamnna
Loading thread data ...

Go to the Atmel website and find the AT91 library AT91LibV214_light.zip or the non-light version. It's about a 9 MB download. In it find a Cstartup.s file. There are more than one, pick the one appropriate for your chip. It should have what you need and plenty of other example code.

Scott

Reply to
Not Really Me

we had a similar problem and the fix was to write 0, 8 times to the end of interrupt register to make sure that all the queued interrupts have been removed ~ do this as the last part of an initialisation process. This efectively flushes all pending interrupts otherwise the whole process gets out of kilter and problems ensue...

Reply to
tim

James, remember to read the timer status register before EOI in the interrupt service, to reset the internal request.

Tauno Voipio tauno voipio @ iki fi

Reply to
Tauno Voipio

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.