This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

__irq keyword

Hi all,

I use a STR912 device from ST. In the examples from their library, the interrupt functions are not preceeded with the __irq keyword.

2 questions :

What is the difference between a normal function and a function preceeded with __irq ?

Is it neccesary to use the _irq keyword in interrupt routines ?

  • Every Register that is modified must be restored when you return from the interrupt routine. The __irq keyword tells the compiler to do this for you. In "normal" functions the compiler may decide that some registers do not need to be saved and may be modified. This is true for R0..R3 which are used to pass parameters into functions, return values from functions and may be used freely within functions.

    I believe that there is a .s file that all interrupt functions go to first in the STR9 libraries and this takes care of saving EVERY register (without consideration of use or not), therefore using the __irq keyword would just re-save any register that was used.