Tedi Tedi - 1 year ago 132
C Question

ARM Interrupt Handler

First to say that I already read this and could not understand or get a clear answer.
I am an AVR guy trying to learn ARM. I am programming the ATSAM4LC2AA from ATMEL.
When I encounter the ISR handler should I disable global interrupts?
And if so is this the correct piece of code?

void USARTx_Handler(void)
/* Disable interrupts */
irqflags_t flags = cpu_irq_save();

/* Read USART Status. */

/* Enable interrupts */

Answer Source

The basic gist of the linked answer is "in the ARM M-profile architecture, you usually don't need to do anything". Taking any exception automatically masks any other exceptions of equal or lower priority. Returning from the exception handler automatically restores the previous state. If you find yourself wanting to mask higher-priority exceptions within a lower-priority handler, start by considering whether you've got your priorities set appropriately in the first place - there are occasional valid reasons for doing so, but if you don't already know why you need to, you don't need to.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download