Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: LPC2129 ARM7 Disable/Enable Interrupt..

2005-05-12 by unikum888

--- In lpc2000@yahoogroups.com, 42Bastian Schick <bastian42@m...> 
wrote:
> Kasper,
> 
> > Inline asm, that I have found and plan to use:
> >
> > #define IENABLE                       \
> >   __asm { MSR     CPSR_c, #0x1F }    /* Enable IRQ (Sys Mode)   
*/   \
> >
> > #define IDISABLE                      \
> >   __asm { MSR     CPSR_c, #0x92 }     /* Disable IRQ (IRQ Mode)  
*/   \
> 
> 
> a) You must be sure you are in ARM mode.
> b) You must be at least in SYS mode.
> c) You should not switch CPU state unless you are sure you know 
what you 
> are
> doing :-)
> 
> I always suggest a small assmembly routine.
> 
> 	.macro SC_TFUNC name
> 	.text
> 	.code 16
> 	.thumb_func
> 	.globl name
> name:
> 	.endm
> 
> 
> /*
> ****************************************
> ** disable interrupts and return old mask
> ****************************************
> */
> 	SC_TFUNC sc_sysLock
> 	bx	pc
> 	nop
> 	.code 32
> 	.globl	sc_sysLock_a
> sc_sysLock_a:
> 	mrs	r0,cpsr
> 	orr	r1,r0,#PSR_I_BIT
> 	msr	cpsr_c,r1
> 	bx	lr
> 
> /*
> ****************************************
> ** restore interrupt mask
> ****************************************
> */
> 	SC_TFUNC sc_sysUnlock
> 	bx	pc
> 	nop
> 	.code 32
> 	.globl	sc_sysUnlock_a
> sc_sysUnlock_a:
> 	and	r0,r0,#PSR_I_BIT
> 	mrs	r1,cpsr
> 	bic	r1,r1,#PSR_I_BIT
> 	orr	r1,r1,r0
> 	msr	cpsr_c,r1
> 	bx	lr
> 
> 
> 
> -- 
> 42Bastian Schick
Hello Bastian
Thanks very much for your answer. Sorry but I do not know asm so 
could you please explain what happens in every line and is the above 
ready to insert in my existing C-code?
Regards Kasper

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.