-
Notifications
You must be signed in to change notification settings - Fork 210
What's the correct way to yield from ISR here? #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think that a task context switch with a Some discussion here. |
Hi Phillip, Thanks for looking into it! Best, |
So this basically means, we can use |
Yet another hint in that direction. |
I think the right answer is to know the preamble for entering an ISR, and then reverse it after doing a context switch. Since we're calling the ISR with I think (untested) that we just need to do the context switch, and then remember to unroll the ISR context save with a context restore. The issue is how the restore context happens. It may need to be before the context switch, or the ISR may never get re-enabled, and we're stuck in it forever. The context switch will require the old context to be saved in the task control block, including the initial address (the return address found on the stack under the ISR context save). And push the new return address (being the last program counter or address run for the switched in task) Need to think more about it... This discussion from avr freaks yields context. |
Any outcome? I searched the Internet once more but found nothing new... |
Need some time to think, code, and test, which is lacking currently. The thing I’m most concerned about is the return address pushed by the ISR when it is entered, and where it has to end up if the ISR exits to a different address. |
Coincidentally, I just found this explanation from Richard, dating back to 2005 but nevertheless. Maybe it's helpful. (I mean the long explanation somewhere near the end of the page.) Best, |
Richard’s 14 June comment is detailed. And comprehensive. But, I don’t fully understand it yet. Will need to draw some stacks to know what to do, and it will take some time. |
This is the sequence provided by Richard, and edited by me, for reference.
I would like to write the answer so that the program execution is not bounced back to the ISR, but rather the real task A SREG and return address replace the SREG and return address of the ISR. This should be quite easily possible, just by popping the real task A return address and pushing it back in the right sequence instead of the ISR program counter during the yield. |
I think, your edition above is correct. So I conclude the following:
Bottom line: Until those optimizations are in place, one can safely use Thanks, |
As the ISR created with the But, still we need to have a clear think about this, and check the asm code generated. |
Hi everyone, |
I think this is now done, with an addition coming from the ATmegaxxxx effort. |
I'll adapt to |
I should do one more alignment release, now that ATmegaxxxx has been merged. Still need to get |
As Thanks for you efforts! 👍 The new AVR128DA/DB series will be a perfect fit for FreeRTOS. Looking forward to Arduino and FreeRTOS support for it, which will surely need some time to mature. Best, |
The AVR128DA28/AVR128DB28 is like someone put most of the Goldilocks Analogue features in one chip. Finally. But, the integrated DAC is a bit weak, given what they could easily have done by integrating the MCP product range, now its even part of the same company. |
Hello Phillip,
The
*GiveFromISR()
functions have apxHigherPriorityTaskWoken
parameter. This can be optionally NULL, but the examples make use of it, stating the actual macro used here is port specific.What's the right macro to use in this AVR port from your point of view? And if it's a macro (and not a function), can it be handled port agnostic using some
#ifdef
s?Thanks,
Flössie
The text was updated successfully, but these errors were encountered: