카테고리 없음

[CorTex-M3] interrupt enabe/disable 방법

벅스바니 2009. 12. 11. 17:16

Link: http://www.st.com/mcu/forums-cat-7137-23.html

You can use the PRIMASK register. When it is set to 1, it disable all
exception except hard fault exception and NMI exception.
To do this, you can use assembler instruction
CPSID I
or
MOVS r0, #1
MSR PRIMASK, r0 ; move R0 into PRIMASK

To re-enable interrupt, you can use
CPSIE I
or
MOVS r0, #0
MSR PRIMASK, r0

If you use RealView Compiler, or KEIL RealView Microcontroller Development Kit, you can use C functions
__disable_irq();
and
__enable_irq();
(http://www.keil.com/support/man/docs/armccref/armccref_cjafbcbb.htm)

Or if you are using the ST firmware library, you can use the functions defined in cortexm3_macros.h
void __SETPRIMASK(void); // disable interrupts
void __RESETPRIMASK(void); // enable interrupts
or functions in stm32f10x_nvic.h
void NVIC_SETPRIMASK(void); // disable interrupts
void NVIC_RESETPRIMASK(void); // enable interrupts
which I believe has the same functions.