This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to enable and disble globle interrupt

Other Parts Discussed in Thread: MSP430G2101

Dear Sir,

                 i am working on msp430g2101 with iar workbench ,i need to enable  globle interrupt enable bit  in status reg  but here no SR is defined and this command is not working SR=(1<<3); or SR|=GIE ; showing error that sr is not defined . so please help me to write proper syntax

  • Hi vivek,

    you can use:

    __enable_interrupts(); // global interrupt enable
    __disable_interrupts(); // global interrupt disable

    to do the job. They were defined in intrinsics.h.

    Rgds
    aBUGSworstnightmare

  • vivek kumar said:
    SR|=GIE

    The C language does not know of the concept of processor registers. It only knws memory location. And SR is no memory location. Actually from a view of a C program, there is no such thing as an SR. (or interrupts and interrupt vector tables)

    To overcome this limitation, the compiler provides som additional keywords that trigger a certain behavior. So-called intrinsics.
    Or the header files define some macros that convert a behavior that is not expressable in C into an assembly instruction.
    In case of GIE, this might be
    EINT(); or DINT();
    or something like this, which expands to inline assembly code "BIS #4, R2" (or more precisely "BIS @R2,R2", by using the constant generator feature of R2).
    If the compiler does not support inline assembly or the problem cannot be solved by a predefined assembly isntruction (like clearing bits on the stack-saved copy of SR, so they will be cleared when leaving an ISR and the SR is restored form stack - required for leaving low power modes), it simply 'knows' these intrinsics as if they were new C keywords and generates the required code.

     

**Attention** This is a public forum