Files
esp-idf/examples/system/nmi_isr
Nebojsa Cvetkovic d0ceef20f4 refactor(xtensa): Rename specreg.h register macros
This commit renames all registers in xtensa/specreg.h to by adding the
prefix XT_REG_. This is done to avoid naming collisions with similar
variable names. A new register file, viz., xt_specreg.h is created. The
previous names are still available to use but have been deprecated.

Closes https://github.com/espressif/esp-idf/issues/12723
Merges https://github.com/espressif/esp-idf/pull/16040
2025-06-17 15:37:33 +02:00
..

Supported Targets ESP32 ESP32-S2 ESP32-S3

NMI ISR Example

This example demonstrates how to allocate and use non-maskable interrupt (NMI) on Xtensa-based targets. The asm_funcs.S file contains the ISR that will be run on the core that installed the NMI. The callback should be fairly simple and must be entirely written in assembly.

Defining an NMI handler can be done by defining a routine named xt_nmi. That routine will be called via call0 instruction, as such, before returning from the ISR, the return address register, a0, must be restored thanks to the instruction:

rsr a0, EXCSAVE + XCHAL_NMILEVEL

How to use example

Hardware Required

Example can run on any Xtensa-based ESP32 development board. Since the example uses GPIO19 as a bi-directional pin, make sure not to connect it to anything.

Configure the project

No particular configuration is required to run this example, the default one is suitable.

Build and Flash

idf.py build flash monitor

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example output

example: Start
example: Success