# Interrpts in FreeRTOS

**URL:** <https://forums.freertos.org/t/interrpts-in-freertos/2013>\
**Category:** Kernel\
**Created:** [May 24, 2009, 2:47pm UTC](https://forums.freertos.org/t/interrpts-in-freertos/2013 "2009-05-24T14:47:53Z")\
**Posts on this page:** 6\
**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:** [May 24, 2009, 2:47pm UTC](https://forums.freertos.org/t/interrpts-in-freertos/2013/1 "2009-05-24T14:47:53Z")

</div>

**[salgat](https://sourceforge.net/u/salgat/)** wrote on [Sunday, May 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/555c28f4/#90cc):

I’m new to embedded OSs and was curious how interrupts work in FreeRTOS. For example, when I receive a message via the UART peripheral and an interrupt occurs, how do I tell FreeRTOS what task to execute to handle that?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 24, 2009, 2:53pm UTC](https://forums.freertos.org/t/interrpts-in-freertos/2013/2 "2009-05-24T14:53:26Z")

</div>

**[sotd](https://sourceforge.net/u/sotd/)** wrote on [Sunday, May 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/555c28f4/#90cc/5834):

Every demo comes with example interrupt to copy. Every demo document page on the web site has a writing an interrupt section.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 24, 2009, 5:59pm UTC](https://forums.freertos.org/t/interrpts-in-freertos/2013/3 "2009-05-24T17:59:30Z")

</div>

**[salgat](https://sourceforge.net/u/salgat/)** wrote on [Sunday, May 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/555c28f4/#90cc/21ee):

I went through my demo, everything worked great, and I read through the website but have not found a page devoted to explaining how interrupts work as far as starting up a specific task. Can you be more specific as to where I can find this?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 24, 2009, 6:14pm UTC](https://forums.freertos.org/t/interrpts-in-freertos/2013/4 "2009-05-24T18:14:32Z")

</div>

**[spacewrench](https://sourceforge.net/u/spacewrench/)** wrote on [Sunday, May 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/555c28f4/#90cc/bb29):

You didn’t post your platform information (at least, not in this thread) so I can’t be more specific, but:

In FreeRTOS, you frequently set up an ordinary task (maybe with a high priority) to handle interrupts.&nbsp; This task spends most of its time sleeping while waiting for a semaphore to be tickled.&nbsp; When an interrupt occurs, the low-level ISR does any work that must happen immediately and then tickles the semaphore.&nbsp; The task wakes up and does whatever else is necessary.

In my code, I have the ISR disable the interrupt at issue, and then the interrupt-handling task re-enables it when everything has been taken care of.&nbsp; I think this is a common way of doing things.

So, to directly answer your question: you don’t have to tell FreeRTOS anything about which task goes with which interrupt.&nbsp; You just set up a semaphore, and have one task that sleeps on it, and an ISR that tickles it.&nbsp; (You could have multiple ticklers if you want, and maybe even multiple sleepers.)&nbsp; There’s nothing special about the ISR-to-interrupt-handler communication that’s any different from any other task-to-task communication.&nbsp; (Except, possibly, that certain FreeRTOS functions can’t be called from the ISR.&nbsp; You can only call functions whose names end in “\_fromISR”)

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 24, 2009, 8:16pm UTC](https://forums.freertos.org/t/interrpts-in-freertos/2013/5 "2009-05-24T20:16:37Z")

</div>

**[salgat](https://sourceforge.net/u/salgat/)** wrote on [Sunday, May 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/555c28f4/#90cc/494d):

This is for the AVR. So what you are saying is that I setup an ISR like I’d usually do without an OS, disable all interrupts, for the UART example do a quick read and copy to an array, and then have a high priority task that will handle the newly modified array after the ISR is completed, correct?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 3, 2009, 9:37pm UTC](https://forums.freertos.org/t/interrpts-in-freertos/2013/6 "2009-06-03T21:37:00Z")

</div>

**[tpham3783](https://sourceforge.net/u/tpham3783/)** wrote on [Wednesday, June 03, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/555c28f4/#90cc/0050):

you’re not alone,

setting up interrupts in free rtos is a little different than the AVR.

There’s a convention in avrs.&nbsp; All Interrupt handlers start with name\_vect (ref.[http://www.nongnu.org/avr-libc/user-manual/group\_\_avr\_\_interrupts.html](http://www.nongnu.org/avr-libc/user-manual/group __avr__ interrupts.html)).

in free tos it is different.&nbsp; However, i found a niffy library that helps in terms of doing anything on the ARM (lib\_AT91SAM7S64.h) \*\*\*google it\*\*\*\*\*  
Pretty much, alot of stand routines of setting up the mcu is reference in that API.
