|
To add to Bob's comments –
1) If you have a number of ISR processes, and add incrementally another ISR, depending
on specific application you can exhaust the MIPs in the machine to respond to ISR events.
2) Most important general principle, in ISR do not make any f() calls, just set a flag and return
to main() to process it. This is a form of MIPs allocation, simply if you run out of MIPs some
threads do not get serviced. You may want more control over this, so you set ISR priorities,
but if you have run out of MIPs in the core, you decide what logically has to run and what
to ignore.
So generally speaking set a flag in ISR, exit, then process in main().
Regards, Dana.
Some more references –
If you added ISR driven code, a couple of rules of thumb -
1) Do not make f() calls from within ISR unless you cannot avoid it. That
is because compiler will do a ton of saves, like full stack, etc. to make sure
it can return fully and properly. That in turn slows machine down considerably.
Look at your listing file to see what the compiler does with your ISR code.
2) Best practice is simple, set a flag inside ISR and return to main() to process ISR.
3) Set up ISR to "fire" as infrequently as possible. If you only need ISR at a low rate,
don't "oversample" it, that would be just a waste of MIPS.
4) Look at coding. If you have multiple ISRs, is there any ISR that can essentially
negate the need to process another pending ISR, eg. compute not when not
needed. If you have an ISR that needs a lot of MIPs occasionally, you can always
skip another pending ISR if by doing so nothing terrible happens.
5) If list file shows compiler generating wacky stuff, consider ASM for the ISR
routine.
6) Turn off optimization when first debugging ISRs, then look at it again after
optimization turned back on, to make sure compiler did not "optimize" in some
crazy jump or other unnecessary code.
7) If display issues are affected, jitter, etc.., consider creating a display buffer in
RAM. And when a write is needed first check if RAM already displaying what you
want, if so do nothing, or update RAM and write to display if needed. This some-
times can cure ISR driven display update issues.
[url]http://www.cypress.com/?id=4&rID=36720[/url]
[url]http://www.planetpsoc.com/component/content/article/43-writing-a-c-isr.html[/url]
[url]http://www.planetpsoc.com/psoc1-articles-digital/13-basics-of-psoc-gpio.html?start=7[/url]
|