# High frequency ISRs in FreeRTOS

**URL:** <https://forums.freertos.org/t/high-frequency-isrs-in-freertos/2009>\
**Category:** Kernel\
**Created:** [February 2, 2010, 8:51am UTC](https://forums.freertos.org/t/high-frequency-isrs-in-freertos/2009 "2010-02-02T08:51:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 2, 2010, 8:51am UTC](https://forums.freertos.org/t/high-frequency-isrs-in-freertos/2009/1 "2010-02-02T08:51:25Z")

</div>

**[peter\_balazovic](https://sourceforge.net/u/peter_balazovic/)** wrote on [Tuesday, February 02, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/5c91c26a/#328b):

Hello all,

I am a new to RTOS and starting to be familiarized with FreeRTOS.  
My intention is to investigate how to integrate motor control into FreeRTOS.  
Usually motor control system (without RTOS) runs Motor\_control\_ISR at 100 periodic rate and code is executed within this Motor\_control\_ISR which takes about 40.  
It is hard real time system where motor control must complete within a given time limit otherwise results in failure of the system.

Are there any handling techniques of such high frequency ISR to comply with FreeRTOS?  
Do you have any suggestions how to handle high frequency ISRs within FreeRTOS?  
Should it be such a ISR executed outside of FreeRTOS?  
Thank you very much.

regards,  
pepe

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 2, 2010, 9:01am UTC](https://forums.freertos.org/t/high-frequency-isrs-in-freertos/2009/2 "2010-02-02T09:01:20Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Tuesday, February 02, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/5c91c26a/#2ce7):

Look at configKERNEL\_INTERRUPT\_PRIORITY and configMAX\_SYSCALL\_INTERRUPT\_PRIORITY at the bottom of [this](http://www.freertos.org/a00110.html) page. These parameters are only on new ports though.

The Cortex M3 demo apps run a 20KHz timer test that shows an interrupt entry jitter of about 100ns which is apparently equal to the effect of tail chaining in the core itself.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 2, 2010, 9:11am UTC](https://forums.freertos.org/t/high-frequency-isrs-in-freertos/2009/3 "2010-02-02T09:11:34Z")

</div>

**[peter\_balazovic](https://sourceforge.net/u/peter_balazovic/)** wrote on [Tuesday, February 02, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/5c91c26a/#5f0e):

Is your suggestion to execute&nbsp; such ISRs outside FreRTOS? (Interrupts running at these priorities will never be delayed from executing because of anything [FreeRTOS.org](http://FreeRTOS.org) is doing. )  
If so, how to interact with FreeRTOS it means between high frequency ISR and FreeRTOS?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 2, 2010, 9:22am UTC](https://forums.freertos.org/t/high-frequency-isrs-in-freertos/2009/4 "2010-02-02T09:22:52Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Tuesday, February 02, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/5c91c26a/#c989):

Yes, if you want the interrupt to have a priority higher than any used by the kernel (including critical sections) then the handler cannot use any FreeRTOS functions.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 2, 2010, 9:26am UTC](https://forums.freertos.org/t/high-frequency-isrs-in-freertos/2009/5 "2010-02-02T09:26:12Z")

</div>

**[peter\_balazovic](https://sourceforge.net/u/peter_balazovic/)** wrote on [Tuesday, February 02, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/5c91c26a/#53ee):

Any idea how to interact between ISR (priority higher than any used by the kernel) and FreeRTOS kernel?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 2, 2010, 9:48am UTC](https://forums.freertos.org/t/high-frequency-isrs-in-freertos/2009/6 "2010-02-02T09:48:17Z")

</div>

**[petermeier](https://sourceforge.net/u/petermeier/)** wrote on [Tuesday, February 02, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/5c91c26a/#2ce9):

You can use anything you like. If you need a buffer just use it and make it globally available. Make sure you have a lock mechanism.

UINT8 bufferLock = 0x00;  
UINT8 buffer;

\_ISR\_(…)  
{  
&nbsp; if (!bufferLock)  
&nbsp; {  
&nbsp;&nbsp;&nbsp; … check buffer data  
&nbsp;&nbsp;&nbsp; …update data  
&nbsp; }  
&nbsp; …  
}

void pvTask(…) // Has a lower priority than the ISR, so pvTask can not interrupt the ISR  
{  
&nbsp;&nbsp; // Try to access buffer, Method 1  
&nbsp; …disable interrupts  
&nbsp; if (bufferLock)  
&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp; // Buffer is in use…  
&nbsp; } else  
&nbsp; {  
&nbsp;&nbsp;&nbsp; // Update buffer here  
&nbsp; }  
&nbsp; …enable interrupts

&nbsp; #Method 2  
&nbsp; …disable interrupts  
&nbsp; if (!bufferLock)  
&nbsp;&nbsp;&nbsp; bufferLock = 0x01;  
&nbsp; …enable interrupts  
&nbsp; if (bufferLock)  
&nbsp; {  
&nbsp;&nbsp;&nbsp; // Update your buffer…  
&nbsp;&nbsp; …  
&nbsp;&nbsp; // Unlock buffer  
&nbsp;&nbsp; bufferLock = 0x00;  
&nbsp; }  
}&nbsp;

This is quick and dirty, but it works…

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 2, 2010, 10:03am UTC](https://forums.freertos.org/t/high-frequency-isrs-in-freertos/2009/7 "2010-02-02T10:03:47Z")

</div>

**[peter\_balazovic](https://sourceforge.net/u/peter_balazovic/)** wrote on [Tuesday, February 02, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/5c91c26a/#d8a6):

Guys,  
Thank you a lot!
