Crossware

Table of Contents        Previous topic       Next topic       

C COMPILER->Interrupt Functions->Register Bank Switching

If you require a fast response from your C interrupt function then you can define your function using the _using n qualifier (in addition to either the _interrupt qualifier or the _interrupt n qualifier).  This will do two things:
    
·It will cause the compiler to generate fast in-line code to save its internal variables
·It will avoid the need to save the registers by switching register banks

However, the compilers floating point data area is not saved and so you cannot use floating point within the interrupt handler.

The compiler will generate code to switch to the register bank defined by the value of n.  Since the compiler uses only one register bank (register bank 0), register banks 1 to 3 are available for use by interrupt routines.

So building upon the examples given above, you might define func() as:

void _interrupt _using 2 func()
{
/* Your interrupt code goes here and must not include anything that uses floating point */
}

with which you will need to manually set up the appropriate interrupt vector to jump to address _func or:

void _interrupt IVN.TIMER1 _using 2 func()
{
/* Your interrupt code goes here and must not include anything that uses floating point */
}

allowing the compiler to set up the timer 1 overflow interrupt vector for you.