This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interrupt called with interrupt

I am facing a problem that while executing a serial receive interrupt my program needs to service a timer0 interrupt. The program is not jumping to the timer0 isr till the uart isr is fully complete even an overflow is generated and interrupt has been enabled ??

  • Does the serial receive interrupt have a lower priority than the timer interrupt? That is required if one interrupt is supposed to interrupt another ISR.

    If both interrupts have the same priority, then they will not interrupt each other, but wait until the other ISR is finished.

  • are you aware of the possible implications of allowing nested interrupts?

  • are you aware of the possible implications of allowing nested interrupts?

    I'm sure OP is going to ask about them when (not if) problems arise. But first things first. :)

    Another solution to the original problem could be, of course, to make the serial receive ISR short enough that is does not cause the timer0 ISR to starve. Keep ISRs short and simple, as Erik would say.

  • .... not realizing that the 'priority' associated with "interrupt number" ONLY apply if the interrupts happen in the same cycle. the ONLY way to interrupt an interrupt is to have different IP priorities.

    Erik

  • I am not familiar with the interrupt function for the mentioned processor but can the 2 interrupts be of the same priority level but in different 'Groups'? Well that again would work only if you have 2 seperate interrupts arriving at the same time.
    For your application it sounds as if it is better to have the timer start and overflow within the first interrupt routing. Am i correct?

  • I woulf like to add that both the intr have different priorities. (serial > higher). Actually I am using timer0 as a time-out to exit the serial ISR waiting for the second byte. The timer0 intr is not generated till I exit the serial ISR, even TF0 is 1.
    I am using different variables for both the ISR so no conflicts.

  • "Actually I am using timer0 as a time-out to exit the serial ISR waiting for the second byte."

    Please stop with that. Do not let your processor busy-loop in any ISR waiting for more events.

    Instead let your main loop wait until your serial ISR collects the second byte or until the timer interrupt (or just polled timer test) indicates a timeout.

    You really should not (!) create "slow" interrupts. It will just complicate everything for you