18.2.2 Jump to NMI Handler (_nmi_handler) if an NMI Occurred

If a Non-Maskable Interrupt (NMI) caused entry to the Reset vector, which is located at 0xBFC00000 on PIC32M MIPS cores, the startup code’s _reset function jumps to an NMI Handler procedure named _nmi_handler. A weak version of the NMI handler procedure is provided that performs an ERET.

To override the default NMI Handler with an application-specific handler, use an assembly-code .S file to create a routine named __nmi_handler. This routine must be written in assembly code because the startup code calls this routine before the C runtime environment is initialized. The __nmi_handler routine must either use only the k0, k1 CPU registers or it must save context before using other registers.