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.

TMS320F28386D: Generate PWM at different freq than ADC SOC

Part Number: TMS320F28386D
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

Hello, I've followed the mulit-axis motor example. There is an interrupt in the middle of each PWM cycle. This has been fine for running at 20KHz.

However, I want the PWM to run at 80KHz but the interrupt and ADC SOC should only be 20KHz.

I've been able to count the interrupts and only run my code every 4th one, but this isn't ideal.

Can you point me to an example or feature that allows me to do this any better? 

Thanks.

  • Hi Ken,

    Our expert will get back on this issue today.

  • Hello Ken,

    Good news! Type-4 ePWM has this feature built-in, with relatively easy configuration. The Event Trigger submodule is able to perform an SOC or an interrupt once ever 'n' events, where n is between 1 and 15. If you're using SysConfig, in the ePWM->Event Trigger->ADC SOC Trigger, the "SOCx Trigger Event Count" does exactly what you're looking for in a clean, quick, and easy way.

    If you'd like to adjust the registers manually, the "EPWM_setADCTriggerEventPrescale(...)" function in C2000Ware's driverlib allows direct control of the Event Trigger Pre-Scale: SOC Pre-Scale Select (ETPS[SOCPSSEL]) register and the Event Trigger Start of Conversion Pre-Scale: SOCx Period2 (ETSOCPS[SOCxPRD2]) register. Long names, but basically;

    • ETPS[SOCPSSEL] = 1 enables the ET to trigger once ever 1-15 events (ETPS[SOCPSSEL] = 0 still allows the ET to trigger once every 1-3 events, but that's not enough for your implementation)
    • ETSOCPS[SOCxPRD2] = x sets the period of the ET SOC trigger to x. In your case, you'd want that to be 4!
    • The function mentioned above takes care of both of these for you, assuming you've enabled the SOC.

    As a note, these features exist for the ET's general interrupts too, not just the SOC.

    Always happy to help,

    Jason Osborn

  • Thanks for the reply.

    That makes sense, but setting EPWM_setADCTriggerEventPrescale   doesn't seem to change anything. I have a scope on my PWM output and a GPIO toggles in the ISR. I can see the GPIO toggle in every PWM cycle.

    But if I change this, it does seem to work     EPWM_setInterruptEventCount(obj->pwmHandle[0], 4);

    Does that make sense? Is this a sign I've got something else wrong?

    thanks

    Ken

  • Hello Ken,

    No, you're alright- I misunderstood what you were doing, that's all! The ET has separate ADC SOC-specific & general interrupt functionality, and I had misread that you were using the former. For general interrupts, EPWM_setInterruptEventCount() is the equivalent function, as you found!

    Regards,

    Jason Osborn