This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Enabling/Disabling Interrupts in LPC23xx using RealView Compiler 3.1

Hi everyone,

I am trying to come up with some macros to enable and disable all interrupts in my LPC2364 while using the Keil RTX and programming in uVision4. After searching through much of the knowledge base, I came across the macros IENABLE and IDISABLE.

unsigned char interrupts_enabled = 0;

#define IENABLE         __asm{ MRS       LR     , SPSR  };  \ 
                        __asm{ STMFD SP!        , {LR}  };  \ 
                        __asm{ MSR   CPSR_c     , #0x1F };  \ 
                        __asm{ STMFD SP!        , {LR}  };  \ 
                        interrupts_enabled = 1;

#define IDISABLE        __asm{ LDMFD SP!        , {LR}  };  \ 
                        __asm{ MSR   CPSR_c     , #0x92 };  \ 
                        __asm{ LDMFD SP!        , {LR}  };  \ 
                        __asm{ MSR   SPSR_cxsf  , LR    };  \ 
                        interrupts_enabled = 0;

Most of that code is a mix of what is suggested in the following links:

http://www.keil.com/support/docs/2910.htm
http://www.keil.com/support/man/docs/armcc/armcc_cihccdja.htm
http://www.keil.com/support/man/docs/armcc/armcc_Chdgbbia.htm

However, I think I am having a problem due to Virtual Registers.
As per the third reference above, we are not allowed to access the LR, SP and PC registers directly.
That is the reason why, obviously, I get errors such as the following:

..\RF\mrfi\radios\common\mrfi_f1f2.c(242): error:  #20: identifier "LR" is undefined

These instructions that access the LR and SP registers are quite significant in what I am trying to achieve though. How can I express this behavior in terms of what inline assembly can do for me? Has anyone done anything like this before, for enabling/disabling interrupts in a LPC microcontroller?