Interrupts Again..

31 Dec 2009 . Edited: 01 Jan 2010

Hey all,

I know this topic has been discussed before but I couldn't really find the answers I'm looking for.

I am in the process of implementing a real-time control system with the mbed. The code will mostly be based on interrupts at the moment and I have a few questions:

What kind of overhead is there when an interrupt occurs?

Is there a performance difference between the different interrupt implementations (InterruptIn, Ticker, TimeOut, Serial etc..)?

Is there a limit to the number of interrupts that can be used at a time (i.e how many functions can be 'attached' to their respective interrupts at the same time)?

Thanks!

01 Jan 2010

Anyone...?

01 Jan 2010 . Edited: 01 Jan 2010
Igor Martinovski wrote:
What kind of overhead is there when an interrupt occurs? Is there a performance difference between the different interrupt implementations (InterruptIn, Ticker, TimeOut, Serial etc..)?

When an interrupt happens, once we're in to the M3 handler itself the timing will be slightly dependant on the type of the interrupt.

For an InterruptIn there is one interrupt vector shared between all the pins, so there is some logic that has to work out which pin caused the interrupt, then call that handler.

For Serial, there is one vector for each UART, so it pretty much calls the handler straight away.

For all the timer interrupts (Timeout, Ticker), all the objects share a single timer/interrupt, and the objects just register an event within a linked list. When the interrupt comes, it just pops the head of the list and calls that handler. A ticker also needs to re-register another event which requires traversing the linked list, but this is at the end of the handler so doesn't impact latency.

I'd guess it is under a hundred cycles all told.

Igor Martinovski wrote:
Is there a limit to the number of interrupts that can be used at a time (i.e how many functions can be 'attached' to their respective interrupts at the same time)?

No, not in theory. The timers are all a linked list so can be as long as you want. But if you don't handle them quick enough, there will be a pile up!

Have a play and see how you get on.

Simon

01 Jan 2010

Thanks Simon, thats exactly what I was looking for.