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.

TMS320F280049C: Interrupt from EPWM-module doesn't work

Part Number: TMS320F280049C


I need help at activating the interrupt from EPWM-module. I use the driver library from TI.

First I initialize the EPWM, without enabling the interrupt in EPWM-module and set the output constantly to low, with the follow function:

 

void InitEPWM8A(void){

 

    EPWM_setClockPrescaler(EPWM8_BASE, EPWM_CLOCK_DIVIDER_16, EPWM_HSCLOCK_DIVIDER_1);

    EPWM_setTimeBasePeriod(EPWM8_BASE, (uint16)EPWM8_TAKT);

    EPWM_setTimeBaseCounter(EPWM8_BASE, 0x0U);

 

    // possibility for initializing an interrupt at 50 µs before ending of period - using Comp_B

    EPWM_setCounterCompareValue(EPWM8_BASE, EPWM_COUNTER_COMPARE_B , EPWM8_COUNT_INTERRUPT);

 

    EPWM_setTimeBaseCounterMode(EPWM8_BASE, EPWM_COUNTER_MODE_DOWN);    

    EPWM_disablePhaseShiftLoad(EPWM8_BASE);

 

    EPWM_selectPeriodLoadEvent(EPWM8_BASE, EPWM_SHADOW_LOAD_MODE_COUNTER_ZERO);

    EPWM_setCounterCompareShadowLoadMode(EPWM8_BASE, EPWM_COUNTER_COMPARE_A , EPWM_COMP_LOAD_ON_CNTR_ZERO);

    EPWM_setCounterCompareShadowLoadMode(EPWM8_BASE, EPWM_COUNTER_COMPARE_B , EPWM_COMP_LOAD_ON_CNTR_ZERO);

    //Enabling interrupt // no enabling of interrupt Completely yet, this will be done at starting EPWM8

    Interrupt_enable(INT_EPWM8);

    EPWM_setInterruptSource(EPWM8_BASE, EPWM_INT_TBCTR_ZERO);

    //EPWM_setInterruptSource(EPWM8_BASE, EPWM_INT_TBCTR_D_CMPB); // for testing

    Interrupt_register(INT_EPWM8, isr_EPWM8);       // Re-map EPWM8 interrupt signal to call the ISR function

    EPWM_clearEventTriggerInterruptFlag(EPWM8_BASE);

    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);

   

   EPWM_setActionQualifierActionComplete(EPWM8_BASE, EPWM_AQ_OUTPUT_A , ( EPWM_AQ_OUTPUT_LOW_ZERO | EPWM_AQ_OUTPUT_LOW_DOWN_CMPA ) ); // setting output to endless zero

}

 

Later, comes the call to start:

void StartEPWM8(void){

    

EPWM_setCounterCompareValue(EPWM8_BASE, EPWM_COUNTER_COMPARE_A , ( (ACTIVE_DISCHARGE_TAKT/10)*9) );

EPWM_setActionQualifierActionComplete(EPWM8_BASE, EPWM_AQ_OUTPUT_A , (EPWM_AQ_OUTPUT_HIGH_ZERO | EPWM_AQ_OUTPUT_LOW_DOWN_CMPA) );

   

//Enabling interrupt

EPWM_enableInterrupt(EPWM8_BASE);

}

 

I have checked configuration of the registers at debugging after activation of the EPWM:

 

- at EPWM-register ETSEL in INTEN interrupt is enabled

- INTSEL the configuration is 001 (Interrupt at time-base counter equal to zero)

- at PieCtrlRegs the 3.8 (for EPWM8) is activated

- at IER-Register INT3 is activated.

 

- Also the NMIE is active and other interrupts are working

  

- PWM is working and I could change the value of the comparator with reaction of the PWM

 

But no Interrupt will occur. The function isr_EPWM8() will not called.

 

Now my question: Is there something missing or wrong? the function StartEPWM8() is called by an interrupt. Could this cause an issue?

 

Thanks for your time and with best regards

  • Hello Marcus,

    did you re-enable interrupts globally via "EINT;" at the end of your initialization?

    I still have in my code:

    // clear interrupt flags
        EPwm7Regs.ETCLR.bit.INT = 1; // Clear INT flag for Epwm7
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP3; // Enable future Epwm (PIE Group 3) __interrupts

    Best regards

    Leon

  • Is there something missing or wrong? the function StartEPWM8() is called by an interrupt. Could this cause an issue?

    Which interrupt is enabling the EPWM interrupt? May not be a good practice but still it should work unless there are any issues with respect to priority or initialization.

    Also as Leon highlighted, I believe the global interrupts and real time interrupts are enabled using EINT and ERTM assembly commands.

    Thanks,

    Aditya

  • Hallo,

    thanks for answering.

    I tried calling outside of interrupt. Without changing.

    Also, clearing interrupt flags immediately after  the line "EPWM_enableInterrupt(EPWM8_BASE);" in EPWM_enableInterrupt(). And using EINT and ERTM again after this line. After intializing all, EINT and ERTM is also called;

    But no interrupt would called from EPWM;

    Interrupt by Input-X-Bar for intializing starting via switch and CPU-Timer1( all 500 µs) for calling ADC works.

  • Hi Markus,

    The ETPS register has a bit named INTPRD which needs to be set. Default value is 0 which will disable the generation of interrupts. You need to use the code mentioned below in your initialization part of EPWM. It should ensure the CPU entering ISR.

    EPWM_setInterruptEventCount(EPWM8_BASE, 3U);

    Thanks,

    Aditya

  • Hi Aditya,

    thank you, this was missing. Now it works!