How to determine which vector caused the interrupt?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to determine which vector caused the interrupt?

2,564 次查看
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
标签 (1)
0 项奖励
回复
3 回复数

1,051 次查看
WOLF
Contributor I
Thanks,    Gives me a Good start.  sample code was greaty apreciated.
0 项奖励
回复

1,051 次查看
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 项奖励
回复

1,051 次查看
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 项奖励
回复