cancel
Showing results for 
Search instead for 
Did you mean: 

Enable/Disable Interrupts globally

kostyak
Associate II
Posted on February 15, 2008 at 22:20

Enable/Disable Interrupts globally

4 REPLIES 4
kostyak
Associate II
Posted on May 17, 2011 at 12:23

Hi !

How can I easily enable / disable all interrupts with one instruction ?

regards

Manfred

joseph239955
Associate II
Posted on May 17, 2011 at 12:23

Not exactly one instruction, but you can disable all interrupts in one go by setting the PRIMASK special register. To do this, you need to use MSR instruction (in assembly):

MOVS R0, #1

MSR PRIMASK, R0 ; Set PRIMASK to 1

Depends on the development tool and library you are using, there might be some device drive function that can do this for you.

ericvanolden9
Associate II
Posted on May 17, 2011 at 12:23

You CAN with only one instruction.

CPSIE I write 0 in PRIMASK so interrupts are enable

CPSID I write 1 in PRIMASK so interrupts are disable

See ARM DDI 0405A-01, page B3-3

With IAR compiler, you have intrinsic function __disable_interrupt() and __enable_interrupt() which put inline these instructions. With GNU compiler you can easily use __asm() directive to put these instructions in your code.

joseph239955
Associate II
Posted on May 17, 2011 at 12:23

Oops, yes of course.

I completely forgot about these two instructions.

Thanks for reminding me :)