PIC32M devices have some interrupts which are persistent, meaning they require the interrupt source to be cleared before the interrupt flag is able to be cleared. PIC32MX and PIC32MZ devices document in the interrupt controller section of their datasheets or in the appendix of their datasheets, whether a particular interrupt source is persistent or not. Refer to the device datasheet for confirmation of whether a particular interrupt is persistent or not.
Note that all sources which cause interrupt flags must be cleared for persistent interrupts to be cleared. For example, when an ADC is scanning 16 channels at once, all 16 channels must be read before the interrupt flag is able to be cleared. Otherwise, execution will hang in the ADC Interrupt Service Routine (ISR).
The direct memory access (DMA) peripheral can be used with peripherals supporting persistent interrupts as well as those without. The general DMA itself does not have persistent interrupts, however, a peripheral dedicated DMA might have a persistent interrupt.
There are other reasons execution may not return from an interrupt routine:
- If the interrupt flag was not cleared in the interrupt routine (this is a simple code bug; you are required to clear interrupt flags in your ISR) execution would not return to the main code.
- A higher priority interrupt could be preventing a low priority ISR from actually continuing execution.
- There could be a timing problem (caused by a code bug) where an interrupt was caused again in the ISR itself from the source of the interrupt being triggered again in the ISR.
- There could be blocking code called through the ISR which prevents the ISR from completing.