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.

Same interrupt occurance during the execution of the interrupt

Other Parts Discussed in Thread: MSP430F5338

Hi all,

I am using msp430f5338. I have a query releated to the interrupt. Say for example an interrupt 'X' is occured and the corresponding ISR will be executed.
During the execution of this ISR, if the same interrut 'X' will be occurred means what will be the result? As per my understanding during the execution of ISR
GIE bit is disabled and it won't allow any other interrupts, but still it allows the same interrupt occurance. Is this correct?

could any one help me to understand this?

Thanks in advance.

  • If the interrupt occurs after your interrupt handler has cleared the module's interrupt flag, then the flag is set again, and the handler will be executed again immediately after it has returned.

    If the interrupt occurs before your interrupt handler has cleared the module's interrupt flag, then the interrupt flag just stays set.
  • Clemens Ladisch said:
    If the interrupt occurs before your interrupt handler has cleared the module's interrupt flag, then the interrupt flag just stays set.

    ... And this flag will be cleared by your interrupt handler later (because it did not clear the flag yet). The new interrupt is lost.

    Your interrupt handler is supposed to clear the flag if it is not already cleared by the hardware automatically. To reduce the chance of losing the next interrupt, you should do that as soon as possible.

    ----

    If the same interrupt occurs yet more times during this, those interrupt are lost. You should keep your interrupt handler short (in time) to reduce that risk.

  • My scenario is looks as below

    This is some pseduocode only and it can be used to explain the scenario which am discussing.

    The below ISR is calling upon the Isrflag1 set due to an interrupt occurred some where in the application.

    Exe_ISR1()
    {
               // some codes;
               // In this time the GIE is disabled so other interrupts are not occurred or the interrupt flags for other interrupts are set and waiting in queue;
                // If Isrflag1 is set during the execution of this ISR, how the system will behave?
                // whether it will call the Exe_ISR1() once again or it simply ignore this interrupt?
                // Does it look like as below ?
    }

    Exe_ISR1()
    {
    // Isrflag1 is set so it called like ---------------------------------------> Exe_ISR1()
    }                                             ^  coming back to the
                                                   |   address where it is                          {
                                                   |   stopped previous ISR                          executing the same code;
                                                   |
                                                   <--------------------------------------------   }

    We can consider the following scenario as one example

    ON a speaker in a phone (Isrflag1 set first time) and immediately OFF the speaker (Isrflag1 set second time) but during the
    execution of the ISR for Isrflag1 set first time. How this kind of scenario to be handled?

    Thanks in advance

  • When the CPU starts an interrupt handler, it automatically clears GIE.
  • Yes, that is correct.

    But usually, the ISR code will do something. For example, it may increment a software counter. Thus, the after the fist time this ISR is executed, that counter changes from 0 to 1. After "executing the same code", that counter changes from 1 to 2.
  • During a interrupt being serviced, no other IRQ will be serviced. (as you should not re-enable GIE bit inside a ISR)
    A new IFG for the same IRQ will not trigger a instant restart, but as soon as it exit but with other IRQ-priority's maybe not instant.

    Really fast multiple hardware triggers is just OR'ed to a single bit flag, so there is no counter to see how many events there should be.
    Using CCR to capture edges will get around the software overhead of a port ISR.
    Using really short ISRs for the whole system that just send flags (or up counts) to a event machine will get around ISR overhead.

**Attention** This is a public forum