Content originally posted in LPCWare by tvink on Fri Jun 05 06:21:06 MST 2015
Hi again,
Thanks for the example. ... but I am going to have more head scratching to do.
Many times you need an atomic _ei() / _di() thing that inlines with your code. In these cases you dont want the overhead of accessing several peripheral registers to stop/start interrupts. Worse yet, if another irq comes in while you are messing with the peripheral registers you may end up with a real mess. For this reason board support packages will include some form of an _ei / _di inline macro.
The 2468 code had this inline in irq.h. It was used but commented out in timer0 C code. When I un comment it, it wont compile. I spent some time trying to figure out how to make it work but was hoping you would have access to a quicker solution. This may be something that only you guys can provide since it requires intimate knowledge of the LPCXpresso assembler and the CPU core. Anyway, your help would be appreciated. Thanks.
#define IENABLE __asm { MRS sysreg, SPSR; MSR CPSR_c, #SYS32Mode }
#define IDISABLE __asm { MSR CPSR_c, #(IRQ32Mode|I_Bit); MSR SPSR_cxsf, sysreg }