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: How to use common EPWM ISR and determine which channel triggered it?

Part Number: TMS320F28379D

Tool/software:

If I were to use a single ISR for all EPWM channels, what is the best method for determining which channel triggered the ISR?

Thanks!

  • Hello,

    There are multiple ways to trigger your ISR. It can be done through several IPs: ePWM, CPUTimer, ADC, eCAP. If you plan to use ePWM to trigger your ISR, I suggest using the "master" ePWM. "Master" PWM is one that sends the sync-out signal to other ePWMs. In case your application requires variable frequency, then I suggest using another EPWM channel that will be static, and its purpose is just to trigger the ISR. 

  • This isn't quite what I am looking for.  

    I will have multiple ePWM channels operating independently and triggering an ISR.  I know how to do this part.  I want to use the same ISR to service each, but I want to still be able to determine which triggered the ISR. 

    For example,

    Interrupt_register(INT_EPWM1, &EPWM_ISR);

    Interrupt_register(INT_EPWM2, &EPWM_ISR);

    Interrupt_register(INT_EPWM3, &EPWM_ISR);

  • Hello,

    Okay, I understand. Is there a specific reason why you're using the same ISR for 3 different PWMs. If you want to know which PWM triggered the ISR, you should just use 3 different ISRs and make the code the same in each. Otherwise, you'll have to read the PIE flags to see which PWM triggered it.

  • Hi Stevan,

    The ISR will be the same for each, and the logic will be a bit complex and subject to change.  Mainly, if I need to make a change, I don't want to manually change the 6 to 9 ISRs and risk a typo.

    The PIE flags do not work (I think), because if for example, EPWM4 triggers the ISR first, but by the time I check the flags, EPWM1 has already set its interrupt flag, so that if I read the IFR register, I will see both EPWM2 and EPWM4 flags and not know which one triggered the ISR.

    I was hoping there might be some other HW flag / register / setting that I could look at, such as the interrupt Vector ID if that is accessible.  

    I think I have a strategy for doing this via software, but need to try it out.

  • Hello,

    You could move ISR code to a function that's shared by all 3 ISRs and pass a parameter to that function that indicates which PWM ISR called that function.

  • This is what I ended up doing.  Thanks!