How to override a Ext. Interrupt over another Ext. Interrupt?

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

How to override a Ext. Interrupt over another Ext. Interrupt?

Jump to solution
1,499 Views
akshaydaga
Contributor III

I am using 2 External Interrupts (EIRQ):

1st EIRQ from SIUL_Ext_Int_isr0_7 having VectorNo.=41 with psrPriority=4 (configured for both Rising & Falling Edge)

and

2nd EIRQ from SIUL_Ext_Int_isr8_15 having Vector No.=42 with psrPriority=1 (configured for both Rising & Falling Edge)

 

In my program, If Rising edge comes on 1st Ext. Interrupt Pin. while 2nd Ext. Interrupt is executing, 1st Interrupt gets masked (1st EIRQ doesn't get envoked) and Vice Versa is also true.

(Though Priority of 1st EIRQ is 4 and 2nd EIRQ is 1)

 

I want,

If Rising edge comes on 1st Ext. Interrupt Pin. while 2nd Ext. Interrupt is executing, 2nd Ext. Interrupt should pause, 1st Ext. Interrupt should get envoked and after completion of 1st Ext. Interrupt 2nd Ext. Interrupt should resume. 

(I want 1st Ext. Interrupt to overcome 2nd Ext. Interrupt) or other way round.

How can I do that?

 

what is significance of following line?

INTC.CPR.R = 0;

I tried this above line but didn't get desired result.

 

 

/******************************************************************************************************/

INTC_InstallINTCInterruptHandler(SIUL_Ext_Int_isr0_7,41,4); /*vector41 for EIRQ0-7 */

INTC_InstallINTCInterruptHandler(SIUL_Ext_Int_isr8_15,42,1); /*vector42 for EIRQ8-15 */

/******************************************************************************************************/

 

and How can I enable Eternal Interrupt using "WKUP"?

 

Please help me through this.

Labels (1)
1 Solution
1,299 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

the feature you need is called Nested Interrupt. It seems you use some CodeWarrior IDE and it is very easy to switch the nested interrupt on. Find the file IntcInterrupts.c and there is defined macro INTC_NESTED_INTERRUPT 0. So change the 0 to 1 and now it will work.

If nested interrupt is disabled and some interrupt is executed, EE bit is set to 0 and all external interrupts are masked (until the executed interrupt is not finished).

If you enable nested interrupt, EE bit is not set to 0 whole time the interrupt is executed and incoming interrupt with higher priority can preempt the executed interrupt.

The INTC_CPR masks any peripheral or software configurable interrupt request set at the same or lower

priority as the current value of the INTC_CPR[PRI] field from generating an interrupt request to the processor.

In your case this means that interrupt with priority 1 is not able to "pause" interrupt with priority 4 even if nested interrupt is enabled. In opposite case it will work.

About wake-up unit, please clarify, which processor you use.

Regards,

Martin

View solution in original post

5 Replies
1,300 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

the feature you need is called Nested Interrupt. It seems you use some CodeWarrior IDE and it is very easy to switch the nested interrupt on. Find the file IntcInterrupts.c and there is defined macro INTC_NESTED_INTERRUPT 0. So change the 0 to 1 and now it will work.

If nested interrupt is disabled and some interrupt is executed, EE bit is set to 0 and all external interrupts are masked (until the executed interrupt is not finished).

If you enable nested interrupt, EE bit is not set to 0 whole time the interrupt is executed and incoming interrupt with higher priority can preempt the executed interrupt.

The INTC_CPR masks any peripheral or software configurable interrupt request set at the same or lower

priority as the current value of the INTC_CPR[PRI] field from generating an interrupt request to the processor.

In your case this means that interrupt with priority 1 is not able to "pause" interrupt with priority 4 even if nested interrupt is enabled. In opposite case it will work.

About wake-up unit, please clarify, which processor you use.

Regards,

Martin

1,299 Views
akshaydaga
Contributor III

Thanks Martin for such a detailed description.

I have 2 interrupts with psrPriority 1 and 4 but I want both the interrupts to have capability to pause another interrupt and perform the task and then resume that paused interrupt.

Can we use "INTC.CPR.R = x;" line to make it possible??

(x: any no. between 0 to 15)

What is significance of CPR and PSR Priority? (I read about it in Reference manual but didn't grasp much)

It will be really appreciable if you can help me through this.

0 Kudos
1,299 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

at first, INTC.CPR register determines, what is processor current priority. It means that current priority masks interrupts, which has lower or equal priority than INTC.CPR.INTC.PSR determines what is the priority of the interrupt.

So you are able to "pause" both your interrupt from each other, but you have to switch current priority to 0 (set INTC.CPR.R = 0) on the beginning of each interrupt and also keep Nested Interrupt enable.

Regards,

Martin

0 Kudos
1,299 Views
akshaydaga
Contributor III

Hi, I tried to pause both interrupts from each other using method you mentioned above. But It didn't

work for me. (I have enabled Nested Interrupt)

When I write "INTC.CPR.R = 0" at the beginning of each interrupt, my program stops working. (Interrupt doesn't get triggered)

for that matter, If I write any value less than psrPriority (4 for 1st Interrupt) and (2 for 2nd interrupt), Interrupt doesn't trigger.

To make it work we need to write "INTC.CPR.R equal to or greater than psrPriority", But in that case these interrupts are not able to pause each other.

I am only able to pause 2nd interrupt (psrPriority=2) and trigger 1st interrupt (psrPriority=4).

Please Help me through this.

/**************************************************************************************************************************/

main()

{

    InitHW();

    Init_eMIOS();

    Init_ADC();

    Switch_PWM_DutyCycle(INITIAL_A_VAL);

    Init_EIRQ();   

   

    INTC_InstallINTCInterruptHandler(SIUL_Ext_Int_isr0_7,41,4); /*vector41 for EIRQ0-7 */ //psrPriority = 4

    INTC_InstallINTCInterruptHandler(SIUL_Ext_Int_isr8_15,42,2); /*vector42 for EIRQ8-15 */ //psrPriority = 2

   INTC.CPR.R = 0; /* Lower current INTC's priority to start ext.interrupts */       

     while(1)

     {    

     }    

}

void SIUL_Ext_Int_isr0_7(void)

{   

INTC.CPR.R = 0;

  if(SIU.ISR.B.EIF5 == 1) // Ext. Interrupt @ PC[2] //Phase-A BEMF

  {

       if(SIU.GPDI[34].B.PDI == 1) //To check Rising Edge //Phase-A BEMF (R.E.) //300Degree

       {

            LED1_ON; //Operations to perform on Rising Edge Interrupt

       }

       else if(SIU.GPDI[34].B.PDI == 0) //To check Falling Edge //Phase-A BEMF (F.E.) //120Degree

       {

            LED1_OFF; //Operations to perform on Falling Edge Interrupt

       }

  }

  else

  {

  }

  SIU.ISR.B.EIF5 = 1; /* Clear interrupt flag */

}

void SIUL_Ext_Int_isr8_15(void)

{

  INTC.CPR.R = 0;

  if(SIU.ISR.B.EIF8 == 1) // Ext. Interrupt @ PC[14] //Current Loop Interrupt

  {

       if(SIU.GPDI[46].B.PDI == 1) //To check Rising Edge //(R.E.)

       {

            LED4_ON; //Operations to perform on Rising Edge Interrupt

        }

       else if(SIU.GPDI[46].B.PDI == 0) //To check Falling Edge //(F.E.)

       {

            LED4_OFF; //Operations to perform on Falling Edge Interrupt

        }

  }

  else

  {

   }

  SIU.ISR.B.EIF8 = 1; /* Clear interrupt flag */

}

/**************************************************************************************************************************/

0 Kudos
1,299 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

please look at the chapters Priority ceiling protocol and Lowering priority within an ISR in reference manual. There are some good tips, how to implement your requirement.

Regards,

Martin

0 Kudos