arm cortex m0+ interrupts enable/disable

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

arm cortex m0+ interrupts enable/disable

跳至解决方案
8,935 次查看
alexleonte
Contributor I

Hi,

I was wondering what is the difference between this two methods for disabling interrupts

1.CPSID causes interrupts to be disabled by setting PRIMASK.

2.Disable all Device-specific interrupts writing in NVIC->ICER[0] + Disable System exceptions (example SysTick - timer and interrupt)

Thx,

标记 (3)
1 解答
4,888 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Alex,

During the initial reset, NVIC is turned off. Therefore, the processor cannot receive any interrupts (except for NMI, Reset interrupt, and hard fault). To turn on the interrupts with configurable priority:

asm volatile ("cpsie i");

“CPSIE I” is a assembly instruction to enable the priority configurable interrupts. Actually, it’s a shortcut to this longer procedure.

1

2

asm volatile ("MOVS r0, #0\n\

MSR PRIMASK, r0");

To turn off the priority configurable interrupts:

asm volatile ("cpsid i");

Or, taking the longer non-atomic procedure:

1

2

asm volatile ("MOVS r0, #1\n\

MSR PRIMASK, r0");

And the NVIC is applicable to enable or disable specific interrupt, the only thing that you need to do is to set IRQ X ‘Set Enable Register’ (ISER) or ‘Clear Enable Register’ (ICER).

Please learn more information about it through the link as below.

ARM Information Center

Hope this helps.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

2 回复数
4,889 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Alex,

During the initial reset, NVIC is turned off. Therefore, the processor cannot receive any interrupts (except for NMI, Reset interrupt, and hard fault). To turn on the interrupts with configurable priority:

asm volatile ("cpsie i");

“CPSIE I” is a assembly instruction to enable the priority configurable interrupts. Actually, it’s a shortcut to this longer procedure.

1

2

asm volatile ("MOVS r0, #0\n\

MSR PRIMASK, r0");

To turn off the priority configurable interrupts:

asm volatile ("cpsid i");

Or, taking the longer non-atomic procedure:

1

2

asm volatile ("MOVS r0, #1\n\

MSR PRIMASK, r0");

And the NVIC is applicable to enable or disable specific interrupt, the only thing that you need to do is to set IRQ X ‘Set Enable Register’ (ISER) or ‘Clear Enable Register’ (ICER).

Please learn more information about it through the link as below.

ARM Information Center

Hope this helps.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

4,888 次查看
pizzburg
Contributor I

This answer is useful. I'm workong on KEA128 with a M0+ core.  

The processer core funciton " __disable_irq"  and  "__get_CONTROL " cannot turn off or turn on interrupts.

But this asm work!     __asm volatile ("cpsie i");    

Solved my problem. 

__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
{
__ASM volatile ("cpsid i" : : : "memory");
}

__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
{
uint32_t result;

__ASM volatile ("MRS %0, control" : "=r" (result) );
return(result);
}

0 项奖励
回复