6.2 Example
The following code snippet demonstrates how a Non-Maskable Interrupt can be implemented.
Non-Maskable Interrupt configuration, CRCSCAN
// io.h includes the device header file with register and vector defines #include <avr/io.h> // interrupt.h contains the ISR related content #include <avr/interrupt.h> void nmi_example(void) { // Configure the CRCSCAN peripheral with NMI CRCSCAN.CTRLB = CRCSCAN_MODE_PRIORITY_gc | CRCSCAN_SRC_FLASH_gc; CRCSCAN.CTRLA = CRCSCAN_NMIEN_bm | CRCSCAN_ENABLE_bm; } ISR(CRCSCAN_NMI_vect) { // If the CRC scan fails, the NMI interrupt will be handled here // The NMI request remains active until a system Reset, and can not be disabled // Check if level 0 or 1 ISRs were interrupted if (CPUINT.STATUS & (CPUINT_LVL0EX_bm | CPUINT_LVL1EX_bm) { } }
For more information on how to prepare a code project for using the CRCSCAN peripheral, refer to Application Note AN2521 - CRCSCAN on Devices in the tinyAVR® 1-Series