Skip to main content
leonhard
Associate II
May 29, 2009
Question

global interrupt enable

  • May 29, 2009
  • 4 replies
  • 4177 views
Posted on May 29, 2009 at 03:25

global interrupt enable

    This topic has been closed for replies.

    4 replies

    leonhard
    leonhardAuthor
    Associate II
    May 17, 2011
    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();

    }

    joseph239955
    Visitor II
    May 17, 2011
    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.)

    rael
    Associate III
    May 17, 2011
    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.

    leonhard
    leonhardAuthor
    Associate II
    May 17, 2011
    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!