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: Continously transfer data to CMPA with DMA if TBCTR=CMPA

Part Number: TMS320F28379D

Hello.

I want to generate more pulses in one ePWM period by transfering the next CMPA value with DMA if TBCTR=CMPA.

Therefore I've configured an SOCA event which triggers a DMA channel. This channel transfers the next action qualifier and CMPA value to the right registers. This transfer is working, I'm able to see in debugger that registers are written correctly. But I'm not gettting any pusle on ePWM output. If I disable DMA transfer with debugger, the last value stays in registers and pulse come out.

Is that generally possible? If yes, any idea what I could have missed?

Thank you
BR
Christian

  • Hi Christian,

    Some questions for you:

    How many pulses are you trying to achieve in a single PWM period? Curious what the use case of this is.

    But I'm not gettting any pusle on ePWM output.

    By this are you saying that the EPWM output is low the entire time (never pulses high at all)? Or do you mean the EPWM pulses only once per period normally based on only one static CMPA value, but does not update accordingly with new CMPA values?

    What is the loading scheme of your CMPA values? Are you using shadow loading? And what are your other EPWM configurations (e.g. count mode, period, action qualifiers etc.)

    Best Regards,

    Allison

  • Hi Allison.

    How many pulses are you trying to achieve in a single PWM period? Curious what the use case of this is.

    ~20 pulses. The use case is a thyristor ignition for a power plant generator exciatation.

    By this are you saying that the EPWM output is low the entire time (never pulses high at all)? Or do you mean the EPWM pulses only once per period normally based on only one static CMPA value, but does not update accordingly with new CMPA values?

    Yes, it is low the entire time. But I can see an update of the CMPA register.

    What is the loading scheme of your CMPA values? Are you using shadow loading? And what are your other EPWM configurations (e.g. count mode, period, action qualifiers etc.)

    Shadowing is disabled. Count mode up. 20ms period. Action qualifier register is also updated from DMA. (SET or CLEAR), DB is disabled. TZ disabled.

    BR
    Christian

  • Hi Christian,

    Thanks for the information. Some more questions for you:

    • What frequency PWM are you looking to run? 50kHz right?
    • Are you looking for variable pulse width or duty cycle? Or are you looking to generate 20 pulses with the same pulse width?
      • If it is the same pulse width, did you consider using the PWM Chopper module?

    Some initial recommendations:

    • Definitely count-up mode (up-down count would complicate it a bit more)
    • Yes, shadow loading should be disabled for CMPA - use immediate mode
    • Instead of updating the action qualifier register every time, you can just use the "Toggle" action qualifier so the PWM channel output toggles high or low on CMPA:
      • You could also try to use both CMPA and CMPB as well and update them both, but that may not be needed here depending on what values you are trying to update to.
    • DMA still needs time to load new values, so be cautious of changing the CMPA to a value close to it (e.g. CMPA = 4 updated to CMPA = 5)

    Let me know if I am misunderstanding - a diagram or quick sketch of what you are envisioning/attempting also never hurts if you have something you can share Slight smile

    Best Regards,

    Allison

  • Hello Allison.

    What frequency PWM are you looking to run? 50kHz right?

    No, It's 50Hz (or 60Hz).

    Are you looking for variable pulse width or duty cycle? Or are you looking to generate 20 pulses with the same pulse width?

    Yes, but only for 1/6 of the period. So I think PWM Chopper doesn't fit.

    It looks like that DMA is too fast. I now have CMPA programmed to make the switch action on the pin, and CMPC to trigger the DMA 5 ticks after CMPA. And this is working (but more compilcated).
    What do you think about the theory that DMA is too fast and writes the next compare value before the AQ engine can perform the action on the pin?

    Best Regards
    Christian

  • Hi Christian,

    Ah yes typo on my side --> 50 Hz Slight smile

    The chopper would have a fixed width and fixed frequency of pulse widths, so I don't think you'd be able to use that here either.

    If I'm understanding correctly, you are saying you need the DMA trigger (to load the next CMPx value) to be delayed? And this is because the counter = CMPx match is supposed to cause both the PWM output to toggle and the DMA to update the next CMPx value, but the DMA transfer is occurring too quickly?

    I know you originally said you are triggering DMA based on EPWM SOCA signal - are you able to have an interrupt that software triggers the DMA instead of using EPWM SOCA as the DMA trigger source (in hardware)? The interrupt would need to be after the action of toggling the output occurs. 

    Best Regards,

    Allison

  • Hello Allison

    If I'm understanding correctly, you are saying you need the DMA trigger (to load the next CMPx value) to be delayed? And this is because the counter = CMPx match is supposed to cause both the PWM output to toggle and the DMA to update the next CMPx value, but the DMA transfer is occurring too quickly?

    Yes, that is my theorie. And it is working if I use CMPA for toggeling the output and CMPC to trigger DMA.

    I know you originally said you are triggering DMA based on EPWM SOCA signal - are you able to have an interrupt that software triggers the DMA instead of using EPWM SOCA as the DMA trigger source (in hardware)? The interrupt would need to be after the action of toggling the output occurs. 

    I've also tried this, not to trigger DMA, but write to CMPA and AQ registers from ISR. It's working. But with interrupts the CPU load increases.

    For me now, the solutions with the two compare registers is working fine.
    Thank you for your help and ideas.

    Best Regards
    Christian