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");
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.
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.
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