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.

Interrupt priority question

Genius 5820 points


This is a question regarding interrupt handling and priorities where it seems I misunderstood something.

Currently I'm using DMTimer2 to create an interrupt every 0,5 usec. Within its ISR I toggle a GPIO output to check interrupt frequency with an oscilloscope. This works fine, I get a clear rectangular waveform.

Now when I initialise USB-stack (which uses an interrupt too), the output waveform is not as clear as before, there are some glitches in it, it seems like the DMTimer-interrupt comes a bit too late sometimes.

My DMTimer2-interrupt uses a priority of 0 (which should be the highest priority) while the USB-interrupt comes with a priority of 120, which should be a very low value.

So my current understanding was this:

  • the low-priority USB-interrupt can't override the DMTimer2-interrupt, means when the DMTimer-ISR is processed, USB can't come in between
  • when the CPU is in USB-ISR and a DMTimer-interrupt happens, the USB-ISR itself is interrupted and the DMTimer-ISR is executed

But this understanding seems to be wrong, elsewhere my DMTimer2-interrupt could not be disturbed by USB-IRQs. So what is the real behaviour when using interrupts with different priorities?

Thanks!

  • Hi Hans,
     
    Hans M��ller said:
    • when the CPU is in USB-ISR and a DMTimer-interrupt happens, the USB-ISR itself is interrupted and the DMTimer-ISR is executed
     
    This assumption is wrong, I think. This is a nested interrupts situation, which is very tricky and could quickly lead to stack overflow. It should be used with extreme care, and only if you are sure exactly how deep the software will go. Please check section 6.1.1.3 of the AM335X TRM Rev. J for explanation of interrupt servicing procedure.
  • OK, your assumption seems to be correct, section 6.2.3 describes the procedure that has to be done explicitely to have nested interrupts.