Disable Interrupts and Enable Interrupts

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Disable Interrupts and Enable Interrupts

1,643 Views
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");

Labels (1)
Tags (1)
0 Kudos
3 Replies

1,558 Views
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 Kudos

1,558 Views
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 Kudos

1,558 Views
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 Kudos