M5223X Interrupt priorities

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

M5223X Interrupt priorities

1,078 Views
mjbcswitzerland
Specialist V
Hi All

Can any one give a definitive answer to the following question?

The M5223X has 2 interrupt controller modules (INTC0 and INTC1), each capable of configuring 56 fully programmable interrupt souces.
When setting up these sources the user must ensure than no two sources are set with the same level and priorities.

The question is, whether this is per interrupt control module or for the whole device?

Eg. In INTC0 one interrupt is set to level 2, priority 5.
It is clear that level 2, priority 5 is now used and must be avoided (in INTC0).
In INTC1 a second interrupt is defined with the same values - level 2, priority 5.

Is this a violation of the rule or is it OK because they are in sererate interrupt controller modules?

Best regards

Mark Butcher

www.uTasker.com

Labels (1)
0 Kudos
1 Reply

274 Views
Technoman64
Contributor III
I have always went by the understanding that no two interrupts could have the same priority wether in seperate INT controllers or same. You do raise an interesting point though. Below is the function I use to set the priority level of an interrupt. This function will try higher or lower priority level based on direction flag if the level being requested is already in use.
 
Code:
//**************************************************************************// char SetInterruptLevel(char Level, char Priority, char Direction, int InterruptVector)//// Paramaters,//  char Level = interrupt request level, valid range 1 to 7//  char Prioriry = priority of the interrupt request level, valid range 0 to 7//  char Direction = TRUE-try higher level. FALSE-try lower interrupt request level//  int InterruptVector = interrupt vector number, valid range 65 to 191//// Returns,//  char = Mask of interrupt level or 0 if error occured//// This function will test to see if the requested interrupt level and// priority have already been used. If not in use the requested level// will be set for the InterruptVector. If the interrupt request level// is already in use higher or lower priority requests will be tried.// The next highest, lowest interrupt request level that is found will// be used. If no higher, lower priority levels are available then an// error will be returned. The returned Mask can be tested to check for// the actual interupt level used.//char SetInterruptLevel(char Level, char Priority, char Direction, int InterruptVector){    // Local variables    int Index;    // Combined Level and Priority register mask    unsigned char Mask = 0;    // Pointer to Interrupt Control Register block, IPSBAR must be defined    volatile unsigned char *ICRn = (vuint8*)(&__IPSBAR[0xc40]);    // Check Level for valid value    if(Level < 1 || Level > 7)        // Return with error        return 0;    // Check Priority for valid value    if(Priority < 0 || Priority > 7)        // Return with error        return 0;    // Adjust Interrupt, all user interrupts are above cpu exceptions    InterruptVector -= 64;    // Check to see which interrupt controller to use    if(InterruptVector > 64)    {        // Use interrupt controller INTC1        ICRn = (vuint8*)(&__IPSBAR[0xd40]);        // Adjust Interrupt        InterruptVector -= 64;    }    // Check for valid interrupt vector    if(InterruptVector < 7 || InterruptVector > 63)        // Return with error        return 0;    // Setup level and priority mask    Mask = Level;    Mask <<= 3;    Mask += Priority;    // Check to see if this level and priority are in use already    // If in use try higher priorty first, if priority fails then    // try higher level. If all higher interrupt levels are in use    // return error else return current interrupt level mask    for(Index = 7; Index < 64; Index++)    {        if(ICRn[Index] == Mask)        {            // Try higher or lower interrupt level—            if(Direction)            {                // Level used already try higher priority                if(Priority < 7)                {                    // Reset Index and check again                    Index = 6;                    // Increase Priority one level                    Priority++;                    // Setup level and priority mask                    Mask = Level;                    Mask <<= 3;                    Mask += Priority;                }else{                    // Reset Priority to lowest level                    Priority = 0;                    // Try a higher Level                    if(Level < 7)                    {                        // Increase Level                        Level++;                        // Reset Index and try again                        Index = 6;                        // Setup level and priority mask                        Mask = Level;                        Mask <<= 3;                        Mask += Priority;                    }else{                        // Return with error                        return 0;                    }                }            }else{                // Level used already try lower priority                if(Priority > 0)                {                    // Reset Index and check again                    Index = 6;                    // Decrease Priority one level                    Priority--;                    // Setup level and priority mask                    Mask = Level;                    Mask <<= 3;                    Mask += Priority;                }else{                    // Reset Priority to highest level                    Priority = 7;                    // Try a lower Level                    if(Level > 1)                    {                        // Decrease Level                        Level--;                        // Reset Index and try again                        Index = 6;                        // Setup level and priority mask                        Mask = Level;                        Mask <<= 3;                        Mask += Priority;                    }else{                        // Return with error                        return 0;                    }                }            }        }    }    // Enter critical section, disable interrupts    OS_ENTER_CRITICAL();    // Set interrupt level    ICRn[InterruptVector] = Mask;    // Exit critical section, enable interrupts    OS_EXIT_CRITICAL();    // Return success (Mask)    return Mask;}

 
0 Kudos