cancel
Showing results for 
Search instead for 
Did you mean: 

global interrupt enable

leonhard
Associate II
Posted on May 29, 2009 at 03:25

global interrupt enable

4 REPLIES 4
leonhard
Associate II
Posted on May 17, 2011 at 13:12

I found the macros __enable_irq() and __disable_irq() to set/clear the I-flag in PSR.

How can I read the I-flag from C-language to do something like the following?

Code:

{

int IFlagTemp;

IFlagTemp = __read_irq(); //this is the NEW function I need!

__disable_irq(); //disable all IRQ's

[my code] //my code, NEVER interrupted by any IRQ

if(IFlagTemp) //re-enable IRQ's if necessary

__enable_irq();

}

leonhard
Associate II
Posted on May 17, 2011 at 13:12

Quote:

The device driver library you are using might might already have a function called __get_PRIMASK(void).

Thank you - this was exactly what I was looking for. I searched for a flag like IEN or GIEN but did not expect a whole register.

Thank you!

rael
Associate II
Posted on May 17, 2011 at 13:12

I'm pretty new at the STM32, and to C too, but I think it needs to be pointed out that the chips have a LOT of built in IO processing functionality, and you shouldn't have to do that task on most applications.

Stuff like the dallas touch button ''1 wire'' interface, you are better to do with interrupts, and queue a timer interrupt for when you need to update a transition, or to capture an edge.

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

Unlike the ARM7TDMI, the Cortex-M3 processor do not have I-flag in the PSR, the interrupt enable and disable is controller by a register called PRIMASK. The device driver library you are using might might already have a function called __get_PRIMASK(void).

If not, you can find it in the CMSIS (Cortex Microcontroller Software Interface Standard) from www.onarm.com. Download the CMSIS, in the zipped file you can find a file Core\CM3\core_cm3.h

The function __get_PRIMASK(void) is what you want.

(The CMSIS supports multiple tools vendors so there are several implementations of the same function.)