Why does PIC32 execution not return from the interrupt routine?

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.
© 2020 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.