Example of an nmi interrupt handler, 2 maskable interrupts, Figure 2−5. nmi interrupt handler – Texas Instruments MSP430x4xx User Manual

Page 27

Advertising
background image

System Reset and Initialization

2-9

System Resets, Interrupts, and Operating Modes

Example of an NMI Interrupt Handler

The NMI interrupt is a multiple-source interrupt. An NMI interrupt automatically
resets the NMIIE, OFIE and ACCVIE interrupt-enable bits. The user NMI
service routine resets the interrupt flags and re-enables the interrupt-enable
bits according to the application needs as shown in Figure 2−5.

Figure 2−5. NMI Interrupt Handler

yes

no

OFIFG=1

yes

no

ACCVIFG=1

yes

Reset ACCVIFG

no

NMIIFG=1

Reset NMIIFG

Reset OFIFG

Start of NMI Interrupt Handler

Reset by HW:

OFIE, NMIIE, ACCVIE

User’s Software,

Oscillator Fault

Handler

User’s Software,

Flash Access

Violation Handler

User’s Software,

External NMI

Handler

Optional

Set NMIIE, OFIE,

ACCVIE Within One

Instruction

RETI

End of NMI Interrupt

Handler

Example 1:

Example 2:

BIS #(NMIIE+OFIE+ACCVIE), &IE1

BIS Mask,&IE1

; Mask enables only
; interrupt sources

Note:

Enabling NMI Interrupts with ACCVIE, NMIIE, and OFIE

Care should be taken when the ACCVIE, NMIIE, and OFIE enable bits are
set inside of an NMI interrupt service routine. This re-enables the interrupt
and can cause stack overflow if the interrupt flag has become set, due to
nested interrupts. When set inside of an NMI service routine, they should be
set by the last instruction of the routine before the

RETI

instruction.

2.2.2

Maskable Interrupts

Maskable interrupts are caused by peripherals with interrupt capability
including the watchdog timer overflow in interval-timer mode. Each maskable
interrupt source can be disabled individually by an interrupt enable bit, or all
maskable interrupts can be disabled by the general interrupt enable (GIE) bit
in the status register (SR).

Advertising