How to determine which vector caused the interrupt?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to determine which vector caused the interrupt?

2,566 Views
WOLF
Contributor I
I know this is not the best example but go with me on this.  If i had all vectors point to the same interrupt function. is there away inside to determine whcih vector was the cause?
 
thanks
Labels (1)
0 Kudos
Reply
3 Replies

1,053 Views
WOLF
Contributor I
Thanks,    Gives me a Good start.  sample code was greaty apreciated.
0 Kudos
Reply

1,053 Views
Arev
Contributor III
Hello,
 
The Vector information is stored in the 'Exception Frame Structure'
You can use one Generic Interrupt asm Handler to save the 'Exception Frame Address' and call a C Function to manage Vector.
 
//---------------------------------------------------------------------------------------------------------------------------------
__interrupt__ void   ISR_Asm_User(void);
 
_ISR_Asm_User:
        lea     -60(SP),SP                        // Stack for 'movem'
        movem.l D0-D7/A0-A6,(SP)        // Save Registers
        pea.l   60(SP)                               // Push 'Exception Frame Address'
 
        jsr     _IRQ_Interruption                // Generic C Fonction IRQ_Interruption(void *ExceptionFrame)
 
        movem.l 4(SP),D0-D7/A0-A6       // Restore Registers
        lea     64(SP),SP                           // Restore SP
        rte
//---------------------------------------------------------------------------------------------------------------------------------
 
void IRQ_Interruption(void *ExceptionFrame_P)
{
register INT Vector_L;

    // Extract Vector Number
    Vector_L = MCF5XXX_RD_SF_VECTOR(ExceptionFrame_P);
 
    // Manage Vector
    if (Vector_L < NB_MAX_VECTORS)
    {
        if (TableIRQ_G[Vector_L].Procedure != NULL)
        {
            // Call Vector Procedure(void *Parameters) from your Own IRQ Table
            (TableIRQ_G[Vector_L].Procedure)(TableIRQ_G[Vector_L].Parameters);
        }
    }
}

//---------------------------------------------------------------------------------------------------------------------------------

I Hope this helps..

Bye
 
<< Freescale MCF5234/35 with CodeWarrior 6.2 >>
0 Kudos
Reply

1,053 Views
stzari
Contributor III
Hi Wolf,

basically it's possible. For this you would have to check the value of the exception stack frame. The  interrupt  vector is  encoded  there.
For more information see Coldfire Family Programmer's Manual  (Ch.  11)  or the  user manual of your processor.

HTH
  stzari
0 Kudos
Reply