AnsweredAssumed Answered

Critical section in MPC5604

Question asked by Remigiusz Machura on Oct 21, 2015
Latest reply on Oct 22, 2015 by Martin Kovar

What is construction for EnterCritical and ExitCritical macro (function) to have part of code without interrupt?

Micro: MPC5604

I found these examples below.

methode #1:

Disable/Enable interrupts


void interrupt_enable_interrupt(void)


  asm(" wrteei 1");   /* Enable external interrupts */


void interrupt_disable_interrupt(void)


  asm(" wrteei 0");   /* disable external interrupts */




method #2:

Save/Restore   interrupt status to local variable

A local variable 'cpu_sr' of type 'vint32_t' needs to be defined in this method.


vuint32_t interrupt_enter_critical(void)


  asm("mfmsr r3");   /* save the register on the local variable */

  asm("wrteei 0");   /* disable the interrupt */


void interrupt_exit_critical(vuint32_t status_reg)


  asm("mtmsr r3");   /* Enable external interrupts */



Somebody used these constructions? Is it working?