This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Interrupt Service Routine – Coding Standards

Hello,

I was recently working on an embedded systems project that requires the use of multiple interrupts. The company I work for has its own set of coding standards of which interrupt service routines are covered.  For the past five years now I’ve been developing code for embedded systems.  In those past five years we always have had the policy of keeping all interrupt service routines as small as possible and we have been strongly encouraged to never call a function from within an ISR.  My boss was recently reviewing this policy and one day came by my desk and asked me why.  Why are function calls inside and ISR a bad thing?  Well, I really didn’t have a good answer for him.  Any thoughts?

Thanks!

  • Some thoughts...:

    - function calls may require pushing/popping parameters on stack, which can be seen as a waste of time

    - I think I recall there can be a (rare) issue with stack alignment when calling a function from an ISR

    - real time control systems usually have strict sampling to output timing requirements, and if you want to minimize the potential headache associated with nested interrupts, it is easier to keep ISR code to a minimum.

    - other than that, ISRs are great