Does anybody know the overhead on the external interrupt feature? I'm looking for a microcontroller for a research project, and I need accurate timing on the order of microseconds.
The STM32F manuals at http://www.st.com/mcu/familiesdocs-110.html
will give these answers in loving detail.
Essentially, the ARM Cortex-M3 has been designed to give deterministic interrupt response times, so, in the absence of multiple interrupts, the times should be very predictable.
know I could do this on a hardware level, I've done similar things in assembly code on different boards, however I'd much rather use C in a user friendly environment like on the maple.
Pretty much everything on a Maple (ARM Cortex-M3) is programmed in C, no assembler required. All peripherals and I/O pins are accessed in C. (This is a key advantage of ARM Cortex-M3 over some earlier generations of ARM)
What I essentially need is to be able to record the exact time an interrupt occurs relative to other interrupts. Basically there will be a half dozen events or so happening potentially within a 30us time frame, and I need to know when they happened relative to each other.
Is it just one set of 6 interrupts, or are there many sets of 6 interrupts?
That may have a bearing on the approach.
You said there are only half a dozen signals.
In that case you could use timers configured to use their input capture pins.
The Maple has four timers, each timer has 4 channels, and each channel has an input capture pin which controls a 'capture register'. So up to 16 input pins can be used to time 16 external signals (I'd need to go check how many of those are available on the Maples 64 pin part, but many more than 6)
When an input capture pin gets a signal, it copies the timer's current counter value into its 'capture register'.
The timer can run at upto 72MHz, so you'd get significantly better resolution than 1uS.
The timer's capture event can simultaneously trigger interrupts, but this is a bit easier than dealing with getting the time in your interrupt handler, as the code just needs to copy the value from the capture register to memory.
(It is possible to have the DMA system put the values into memory, so there is only one interrupt to worry about, i.e. when all 6 values have been captured, but one thing at a time :-)
If you switch off interrupts, the processor could miss one, and an event would be lost. Is this okay?
If I use an external interrupt will it immediately execute my code?
That depends on whether or not interrupts are disabled, and if there is a higher priority interrupt running. If interrupts are disabled, no, it won't execute your code. If there is a higher priority interrupt the lower priority must wait until the higher priority interrupt handler exits.
Are there any automatic maintenance routines that would delay only one interrupt?
Yes, there is a millisecond timer which would have to be switched off, which you can do in software.
There is also a USB connection. I'm not sure if there is anything that needs to be done about this. Maybe a LeafLabs person can answer.
Any other issues you can think of off-hand?
Certainly start by doing it in software, to get the feel of the system. But be prepared to dig into timers if it is important that it is very accurate and predicable.
Other than suggesting you don't do this in software, but instead let the hardware timers do the job for you, I can't think of any other issues.