Interrupt Priority

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

Interrupt Priority

1,711 Views
anbui
Contributor II

Where can i find the default interrupt priority for the  dspi, i2c, and gpio drivers for the freedom k22f board.

Labels (1)
0 Kudos
1 Reply

840 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Kinetis K22 product using ARM Cortex-M4 core. The interrupt priority setting at NVIC_IPRx register.

2016-04-05_14-34-59.jpg

Please refer below code to set interrupt priority:

/*ARM Cortex M4 implementation for interrupt priority shift*/

#define ARM_INTERRUPT_LEVEL_BITS          4

/***********************************************************************/

/*

* Initialize the NVIC to set specified IRQ priority.

*

* NOTE: The function only initializes the NVIC to set a single IRQ priority.

* Interrupts will also need to be enabled in the ARM core. This can be

* done using the EnableInterrupts macro.

*

* Parameters:

* irq    irq number to be enabled (the irq number NOT the vector number)

* prio   irq priority. 0-15 levels. 0 max priority

*/

void set_irq_priority (int irq, int prio)

{

    /*irq priority pointer*/

    uint8 *prio_reg;

   

    /* Make sure that the IRQ is an allowable number. Right now up to 105 is

     * used.

     */

    if (irq > 105)

        printf("\nERR! Invalid IRQ value passed to priority irq function!\n");

    if (prio > 15)

        printf("\nERR! Invalid priority value passed to priority irq function!\n");

   

    /* Determine which of the NVICIPx corresponds to the irq */

    prio_reg = (uint8 *)(((uint32)&NVICIP0) + irq);

    /* Assign priority to IRQ */

    *prio_reg = ( (prio&0xF) << (8 - ARM_INTERRUPT_LEVEL_BITS) );            

}

/***********************************************************************/


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos