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.

LAUNCHXL-F280049C: Strange behaviour when using ePWM Counter Compare out of bounds of period

Part Number: LAUNCHXL-F280049C

Hi there,
first up I want to ask you to be gentle since this is my first post.
As the title suggests, I am experiencing some strange behaviour when trying to use the counter compare when the counter is running above the specified period.

The setup:
I am using Simulink C2000 integration for code generation and deployment onto the Launchpad. Therein I am using the ePWM Type 1-4 Blocks to configure the registers.

I am using ePWM1 to generate a "low frequency" sync pulse which is used to sync and thereby set the phase of ePWM 2 to a value. ePWM 2 is counting at a much higher pace and is counting in up/down mode.


What i wan to achieve:
For a complicated pulse pattern, which I want to create, I want to set the time base counter to a value above the specified period for that register. The counter should (since it is in up/down mode):
- normally count
- then get synced to a value higher than the period (T = 5000) (in my case 60000), counting up after the sync
- then after a bit of counting reach Compare Match A and consequently set the pin
- then reach 65535 and flip its counting direction
- after a bit of counting down reach Compare Match A again and consequently clear the pin
- then count down further until it reaches 0
- start a new period which is unaffected by the previous sync 

What I have found:
The Compare Match works as long as the action carried out by compare match A doesn't change the pins output (so for example the pin is already low and is cleared by the compare match action).

The Compare Match works perfeclty with an action that alters the pattern if it's value is smaller than the period.

As soon as I set the value of compare match A to something greater than the period and set the action of compare match A to something that would alter the pattern, the PWM pattern completely dissappears from the pin.

If you need more info please tell me, I am curious if this behaviour is defined or if it may even be simulink that is the killjoy.

  • Hi Peter,

    No worries if you are new here Slight smile. This is indeed an interesting case. Can I ask overall what sort of PWM signal you are trying to generate? This is not a typical configuration of PWM settings so I'm want to see if there is an easier way to accomplish what you are trying to do (if we can't get this to work, that is).

    Can you share your PWM configurations/initialization so I can also see more context of what you are trying to do at the moment?

    Are you checking the PWM counter and counter direction to see if it is indeed counting up all the way to 65535 and then confirm it is changing count directions after? I know that if the counter is set to greater than the TBPRD value, it can keep counting up and overflow back to 0 for up-count.

    When you say the PWM pattern disappears, do you mean that no further pulses are generated at all (signal remains only in a low or high state)? Or do you mean the pulses stop for a cycle and resume after?

    Best Regards,

    Allison