This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

What is the interrupt behavior in Cortex M3

Other Parts Discussed in Thread: EK-TM4C123GXL

I have set pin interrupt.

1. When enter in ISR, I have cleared the interrupt clear flag (not interrupt enable/disable fllag.)

However I have kept my ISR small. But I want to know what will happen if same interrupt come while control is in  ISR.

2. While I am in higher priority interrupt & low priority int comes, then I think control will enter in low ISR after executing first ISR

3. Also what if more higher priority interrupt comes, will control jumps to that ISR first, or it will execute current ISR first & then go to higher ISR

  • Aamir,

    In answer to your questions:

    1) if the same interrupt is triggered after you have cleared the flag but before the interrupt has finished then the interrupt will finish processing, return, and then immediately be thrown back into the interrupt again. The interrupts would happen one after the other.

    2) correct, assuming the high and low refer to the priority of the interrupt and not the number (keep in mind the lower the number the higher the priority, 0 has the highest priority)

    3) if a higher priority interrupt comes in then it will preempt the current interrupt and the context will be switched to it and then be returned to the lower priority interrupt when it is finished. It would look like this

    ____

    |

    |

    Low Priority Int

    |

    |

    ________

          |

          High Priority Int

          |

    ________

    |

    Finish Low Priority Int

    |

    ____

    Regards,

    Austin

  • @ TI Austin:  Believe your verbage - and especially the amplifying drawing - make your response superb.  Well done - thanks...

    Perhaps one slight addition - should the particular interrupt service be of great importance - upon entry to that "key interrupt service" - all interrupts can be disabled - insuring that this special interrupt is serviced w/out any disruption.  Last entry w/in this key interrupt service must then "re-enable" all interrupts.

  • Joseph Yiu, "The Definitive Guide to the ARM Cortex-M3, 2nd Edition"

    http://store.elsevier.com/product.jsp?isbn=9781856179638

  • Thanks Austin for the explanation.

    Can you please provide some example code to demonstrate how to increase the priority of Interrupt so that it pre-empts the current interrupt and then NVIC restores it ?

    Thanks,

    Sanchit Mehra 

  • Hello Sanchit,

    You may want to go through the following TIVAWare example

    C:\ti\TivaWare_C_Series-2.1.0.12573\examples\boards\ek-tm4c123gxl\interrupts

    Regards

    Amit

  • Ok . 

    Thanks Amit .

    Now, i am setting the following priorities 

    ROM_IntPrioritySet(INT_GPIOQ1,0x40); // low priority
    ROM_IntPrioritySet(INT_TIMER2A,0x00); // high priority

    So, if the Timer(timeout interrupt) interrupt comes in between the GPIOQ1 Pin interrupt , then pin Interrupt should be Pre-empted and TIMER2A Interrupt should be handled first and then Pin Interrupt should be restored.

    Am I right ?

    Thanks,

    Sanchit

  • Hello Sanchit

    Yes, I confirm your statement.

    Regards

    Amit

  • Hello Amit, 

    Actually I am starting the timer in between the GPIOPin Q1 interrupt routine.

    int timerdone = 0;

    void GPIOPIntHandler(void) // interrupt handler for GPIO event

    ROM_IntEnable(INT_TIMER2A);
    ROM_TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
    ROM_TimerEnable(TIMER2_BASE, TIMER_A); // enable the timer in the routine

    while(timerdone == 0) {UARTprintf("waiting for timer interrupt");  ......}

    }

    the Timer interrupt doesnot execute in between the GPIOINT routine ..

    void Timer2IntHandler(void)

    {

    UARTprintf( "in timer routine \n";

    timerdone = 1;....

    }

    Please suggest.

    Thanks,

    Sanchit

  • Hi, 

    I just printed the following things:

    UARTprintf("\nPriority of Timer 2A is %d\n",ROM_IntPriorityGet(INT_TIMER2A));
    UARTprintf("\nPriority of GPIOQ1 is %d\n",ROM_IntPriorityGet(INT_GPIOQ1));
    UARTprintf("\npreemtable priority bits is %d \n",ROM_IntPriorityGroupingGet());
    UARTprintf("\n Priority Masking : %d \n",ROM_IntPriorityMaskGet());

    Priority of Timer 2A is 0

    Priority of GPIOQ1 is 128

    preemtable priority bits is 7

    Priority Masking : 0

    Masking is 0, So Will there be any effect on Interrupt prioritization ?