fastest possible interrupt

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Tinker
Posts: 14
Joined: Tue Feb 28, 2012 6:55 pm

fastest possible interrupt

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: fastest possible interrupt

Post 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
Tinker
Posts: 14
Joined: Tue Feb 28, 2012 6:55 pm

Re: fastest possible interrupt

Post 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)
Post Reply