Disable Interrupts and Enable Interrupts

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Disable Interrupts and Enable Interrupts

2,268件の閲覧回数
Deepak1
Contributor IV

I am using MPC5748G micrcontroller.

During executing some operations I want to disable interrupts and then want enable interrupts. Below is the code I that i am using for the same.

Please let me know is this correct implementation  ? you can also suggest me better method. 

/* Disable Interrupt */
#define DISABLE_INTERRUPT \
__asm volatile("mfmsr %0" : "=r" (msr) :);\
if (msr & (uint32)0x00008000UL)\
__asm(" wrteei 0");

/* Enable Interrupt */
#define ENABLE_INTERRUPT \
if (msr & (uint32)0x00008000UL)\
__asm(" wrteei 1");

ラベル(1)
タグ(1)
0 件の賞賛
返信
3 返答(返信)

2,183件の閲覧回数
petervlna
NXP TechSupport
NXP TechSupport

Hi,

I do not have any knowledge on your compiler, but yes the wrteei instruction enable/disable external interrupt processing to core.

regards,

Peter

PS: Execution of this instruction is privileged and restricted to supervisor mode only.

0 件の賞賛
返信

2,183件の閲覧回数
Deepak1
Contributor IV

Hi Peter,

Sorry i forgot to mention about compiler.

I am using GCC compiler and IDE is S32DS Power v2.1.

I want to disable and enable internal as well external interrupts.

0 件の賞賛
返信

2,183件の閲覧回数
petervlna
NXP TechSupport
NXP TechSupport

Hi,

I am not using GCC, but this should work.

I will check it with the gcc expert and let you know in case I am wrong.

regards,

Peter

0 件の賞賛
返信