Indeed its getting offtopic but great that everybody has an opinion
, the problem here are the requirements and if the input signals are known and predictable.
And luckily in this case they are:
In this case I know what the nature of the input signal is like and where the time critical paths are
In my own experience however I have seen a lot of accidents happen with ADC sampling and directly in the ISR calculating all the (sometimes very complex) math for results that are NOT directly necessary. For instance energyconsumption. The requirements state for instance that this should be accurate every few seconds, so in those cases you can store the results and postpone the final calculation or do this over time with averaging. Also this code grows over time, new requirements and SW engineers, putting the extra code on top of the existing (inside the ISR), failure waiting to happen.
He said "have to be complete before the next edge" how does trying to offload the calculations to foreground execution help meet that requirement in any way?
In this case it probably doesn't, it does help however porting to another microcontroller , platform and overall readability, all which become more important these days then making it work on a single platform.
You can't ask a 3 phase motor to wait a bit for the PWM sine waves you are generating because your foreground code was servicing a query on a serial port.
True that's a matter of prioritizing the tasks. In the given case the calculations should have higher priority over a slow serial port query.
However the query should still be processed at some time also otherwise your system seems to be dead from an outside point of view.
The worst advice I've ever seen. The only reason to make an ISR short is when there is a chance another ISR can kick in which needs to be serviced.
That was exactly my point that the exact same interrupt is not going to be handled because the ISR is still in the middle of its calculations. You loose events and valuable information that is not going to be processed because the timer value that needs to be stored is increasing with every instruction you waste in the mean time and the results will be false.
A controller has X time to handle Y instructions. Moving calculations outside an ISR doesn't mean that X or Y changes so it doesn't matter where you do the math. You need to do it anyway.
Depends on the requirements if you need to do it right away or it can be handled in between events or even delayed for some times.
I firmly believe ISRs need to be as small and simple as possible do what they need to do and return. Do the prioritizing of the tasks in your taskshandler, if you have an RTOS and else write it yourself.
But then again most microcontrollers support nested interrupts.
Hooray, good luck handling the exact same interrupt you are already handling.
But I think we mean the same thing, you will probably say you have to make sure that the computations are finished before the next event comes which is correct. That said you sometimes don't know when the next event comes. If the whole point of the interrupt and thus the ISR is to simply store the exact timervalue at the exact moment of the interrupt, you better make sure that that interrupt is getting handled immediately which means keep the ISR to it's minimum.
Anyone interested in ISR's should take a Rate Monotonic Analysis course, very worth while