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.

TMS320F28379D: pwm ISR not triggered when PWM is counting down in up-down mode

Part Number: TMS320F28379D

Tool/software:

Hello Experts,

I have configured ePWM11 in up-down mode and trying to enable pwm interrupts when TCBR is zero or period by writing the INTSEL bit as 011 

EPWM_setInterruptSource(EPWM11_BASE ,EPWM_INT_TBCTR_ZERO_OR_PERIOD);

Am I correct is asuming that 2 interrupts will be generated , one when TCBR = 0 and the other when TCBR = Period, for every PWM cycle(marked in red)?

Now , when TCBR is 0, if i check the direction (TBSTS.CTRDIR), am i correct in asuming that the counter will be counting up? And when TCBR is equal to Period, the counter will be counting down?

I tried to verify the above , by checking the direction in the PWM ISR, but it always shows as theough it is counting up, it never counts down, I tried to toggle a GPIO to verify this but is is always low!! 

__interrupt void pwm11_ISR(void)
{
    pwm_CounterDIR = EPWM_getTimeBaseCounterDirection(EPWM11_BASE);
    testTCBR1 = EPWM_getTimeBaseCounterValue(EPWM11_BASE);
	
    if(EPWM_getTimeBaseCounterDirection(EPWM11_BASE))
    {
        GPIO_writePin(46,0);
    }
    else
    {
        GPIO_writePin(46,1);
    }

	testTCBR2 = EPWM_getTimeBaseCounterValue(EPWM11_BASE);
	
    EPWM_clearEventTriggerInterruptFlag(EPWM11_BASE);
	ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
	Interrupt_clearACKGroup( INTERRUPT_ACK_GROUP3 |
                             INTERRUPT_ACK_GROUP11 );

}

What configuration am i missing here?

If i set the interrupt source as :

EPWM_setInterruptSource(EPWM11_BASE ,EPWM_INT_TBCTR_ZERO);, Then the GPIO is always Low.

Similarly if i set the interrupt source as 

EPWM_setInterruptSource(EPWM11_BASE ,EPWM_INT_TBCTR_PERIOD);, Then the GPIO is always High.

But when i set the interrupt source as 

EPWM_setInterruptSource(EPWM11_BASE ,EPWM_INT_TBCTR_ZERO_OR_PERIOD);, The GPIO is always Low!!, 

  • Hello AK,

    Am I correct is asuming that 2 interrupts will be generated , one when TCBR = 0 and the other when TCBR = Period, for every PWM cycle(marked in red)?

    Yes.

    Now , when TCBR is 0, if i check the direction (TBSTS.CTRDIR), am i correct in asuming that the counter will be counting up? And when TCBR is equal to Period, the counter will be counting down?

    Also, yes.

    My first questions is: if you set a breakpoint in the ISR, is the breakpoint getting hit at all? If not, we can confirm that the ISR is not getting called and look further into the configurations. Can you also provide a snippet of your EPWM init?

    Best Regards,

    Allison

  • Hi Allison,

    I figured out the issue, In my pwm initializer , even though i was setting the epwm source EPWM_INT_TBCTR_ZERO_OR_PERIOD, i am also triggering ADC SOC with the same PWM , but the ADC trigger source was configured as EPWM_SOC_TBCTR_ZERO only.

    EPWM_setADCTriggerSource(EPWM11_BASE, EPWM_SOC_A,EPWM_SOC_TBCTR_ZERO);

    Once i had changed this to 

    EPWM_setADCTriggerSource(EPWM11_BASE, EPWM_SOC_A,EPWM_SOC_TBCTR_ZERO_OR_PERIOD); , now i am able to detect both the up count and down count directions. Slight smile

  • Glad to hear you've resolved it! Thanks for posting the solution Slight smile