Amanpreet Singh
Amanpreet Singh

Reputation: 1

How to enable nested interrupts in msp430g2553?

I want to enable nested interrupts on msp430 as I want to use UART in the ISR of a Timer.

Upvotes: 0

Views: 1537

Answers (1)

kfx
kfx

Reputation: 8537

Whenever msp430 microcontroller is about to start to execute an interrupt handler function, the first thing it does is to disable the global "interrupts enabled" flag, which is a bit in the status register r2. That effectively prohibits interrupt nesting by default.

To work around this, enable interrupt by setting the register flag back to 1 at the start of your interrupt handler functions. To simplify the syntax, there's actually an eint instruction for this:

asm("eint");

Typically there are also compiler-specific macros for emnabe that let you avoid writing assembly code. This should work both with GCC and IAR:

__enable_interrupt();

(Please, do not abuse interrupt nesting. In most cases there's absolutely no need for it. It's almost certainly a better idea to change your design than to go for it.)

Upvotes: 3

Related Questions