This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

nested interrupts Epwm and timer1

Hi,

    I am using three different interrupts: ePWM1, Timer 1 and Timer 2. As per the priority PWM should not get interrupted by other two. But practically that is not happening.

  Now I want to use nested interrupts, where I can enable and disable interrupts within interrupt depending on priority. Is it possible?


Regards,

Nayana

  • Hi Nayana,

    This link would give you all info on Interrupt Nesting:

    http://processors.wiki.ti.com/index.php/Interrupt_Nesting_on_C28x

    Regards,

    Gautam

  • Hey Gautam,

    I followed the same procedure as mentioned in the link, But I did not get the expected output.

    In the following example instead of group2 interrupt i am using group 3. I need to disable timer1 interrupt(lower group interrupt should not interrupt higher priority interrupt) within ePWM interrupt. please help me with that.

    // C28x ISR Code
    //
    // Enable nested interrupts 
    //
    //
    interrupt void EPWM1_TZINT_ISR(void) 
    {
        uint16_t TempPIEIER;
        TempPIEIER = PieCtrlRegs.PIEIER2.all; // Save PIEIER register for later
        IER |= 0x002;                         // Set global priority by adjusting IER
        IER &= 0x002;                         
        PieCtrlRegs.PIEIER2.all &= 0x0002;    // Set group priority by adjusting PIEIER2 to allow INT2.2 to interrupt current ISR
        PieCtrlRegs.PIEACK.all = 0xFFFF;      // Enable PIE interrupts
        asm("       NOP");                    // Wait one cycle
        EINT;                                 // Clear INTM to enable interrupts
        //
        // Insert ISR Code here.......
        // for now just insert a delay
        //
        for(i = 1; i <= 10; i++) {}
        //
        // Restore registers saved:
        //
        DINT;
        PieCtrlRegs.PIEIER2.all = TempPIEIER;
    }
    #endif

    Thanks & Regards,

    Nayana

  • That's very strange that you're not getting the expected output. Do also go through this link for detailed info on nested interrupts:

    http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/311734.aspx

    Regards,

    Gautam

  • Hi Gautam,


        This is my code,

    ePWM 1 period is 62 uSec and CPU timer1 period is 100 uSec

    interrupt void epwm1_timer_isr(void)
    {

       GpioDataRegs.GPASET.bit.GPIO22=1;
       for(i=10; i>0 ; i--)                        //10us delay
       {
               for(j=7; j>0; j--)
               {
                  k++;
               }
       }
       GpioDataRegs.GPACLEAR.bit.GPIO22=1;
       //EPwm1TimerIntCount++;

       // Clear INT flag for this timer
       EPwm1Regs.ETCLR.bit.INT = 1;

       // Acknowledge this interrupt to receive more interrupts from group 3
       PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
    }

    interrupt void cpu_timer1_isr(void)
    {

      GpioDataRegs.GPASET.bit.GPIO23=1;
      for(i=25; i>0 ; i--)                            //25us delay
           {
               for(j=7; j>0; j--)
               {
                   k++;
               }
           }
      GpioDataRegs.GPACLEAR.bit.GPIO23=1;
       //CpuTimer1.InterruptCount++;

       // The CPU acknowledges the interrupt.
       EDIS;

    }
     but epwm pulse is getting delayed because of timer.

    If i try to incorporate code given in link i am not getting the output at all. I tried attaching the screen shots but getting error.

    Regards,

    nayana