# \[AVR\] portYIELD\_FROM\_ISR should be provided

**URL:** <https://forums.freertos.org/t/avr-portyield-from-isr-should-be-provided/843>\
**Category:** Kernel\
**Created:** [April 18, 2013, 6:54am UTC](https://forums.freertos.org/t/avr-portyield-from-isr-should-be-provided/843 "2013-04-18T06:54:18Z")\
**Posts on this page:** 2\
**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:** [April 18, 2013, 6:54am UTC](https://forums.freertos.org/t/avr-portyield-from-isr-should-be-provided/843/1 "2013-04-18T06:54:18Z")

</div>

**anonymous** wrote on [Thursday, April 18, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/265d6cf3/#72fb):

I think that there should be macro portYIELD\_FROM\_ISR and function vPortYieldFromISR() added to ATMega323 port.  
This is becouse vPortYield() uses “ret” to return, but if current contex was switched in vPortTickFromISR(), restored SREG do not have global interrupt flag set.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [April 18, 2013, 8:02am UTC](https://forums.freertos.org/t/avr-portyield-from-isr-should-be-provided/843/2 "2013-04-18T08:02:15Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, April 18, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/265d6cf3/#9adb):

This (extremely old) port is explained in on the following (extremely old) web pages.&nbsp; I have only linked to the two relevant pages:

[http://www.freertos.org/implementation/a00016.html](http://www.freertos.org/implementation/a00016.html)  
[http://www.freertos.org/implementation/a00017.html](http://www.freertos.org/implementation/a00017.html)

SREG is saved and restored as part of the task context.&nbsp; When a task that is switched out from an interrupt is next executed it will be switched back into the interrupt (from exactly where it was switched out) - where it will execute its end of interrupt code setting SREG back to its required value.&nbsp; Likewise if a task is switched in from inside an interrupt it will start executing from wherever it was switched out - which may or may not be in an interrupt but its SREG will also be correct for wherever it ends up.

Regards.
