5.5.8 How Can I Make My Interrupt Routine Faster?

Try the following suggestions for faster ISR execution:

  1. Smaller code is often faster code. For details, see the following section of this user’s guide:

    How Can I Make My Code Smaller?

  2. Suggestions to make code faster also work for ISR code. For details, refer to the following section of this user’s guide:

    How Can I Make My Code Faster?

  3. Consider having the ISR simply set a flag and return. The flag can then be checked in main-line code to handle the interrupt. This has the advantage of moving the complicated interrupt-processing code out of the ISR so that it no longer contributes to its register usage. Always use the volatile qualifier for variables shared by the interrupt and main-line code; see the following sections of this user’s guide:

    Volatile Type Qualifier

    How Do I Share Data Between Interrupt and Main-line Code?