Page 1 of 1

fastest possible interrupt

Posted: Mon Apr 02, 2012 8:39 pm
by Tinker
Hi,

I need to run an interrupt as fast as possible, if only for just a test, so I want to see disable anything that may preempt it. How can I achieve this? Right now I removed the prologue and epilogue and typed this directly:

#undef port_lock
#undef port_unlock
#define port_lock() asm volatile ("cpsid i" : : : "memory")
#define port_unlock() asm volatile ("cpsie i" : : : "memory")

port_lock();
/* interrupt code */
port_unlock();

but still have a lot of variation (I'm toggling a pin).

Is there a way to ensure this interrupt is not preempted at all?

T

Re: fastest possible interrupt

Posted: Mon Apr 02, 2012 9:06 pm
by Giovanni
Hi,

You don't need to change anything. It is possible to have interrupts that are never preempted, you have to assign them a priority higher than CORTEX_BASEPRI_KERNEL (just priority zero, the highest, using the default settings).

Also, the interrupt handler then is assumed to be "fast" and must use a slightly different declaration, see the article:

http://www.chibios.org/dokuwiki/doku.ph ... interrupts

There are no prologue and epilogue.

Fast interrupts are never preempted except from other fast interrupts with higher priority however fast interrupts cannot interact with the kernel directly, if needed you can perform an indirect communication by triggering a PENDSV software interrupt which is executed at kernel priority (this is often called segmented interrupts handling).

Giovanni

Re: fastest possible interrupt

Posted: Mon Apr 02, 2012 11:00 pm
by Tinker
Thanks! I hadn't realized you had foreseen this need already.

I should probably re-read the documentation periodically :)

I got an SPI slave working at 4.5 megabits/s! (without DMA, the type of SPI protocol that responds immediately)