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.

MSPM0L1306: PWM Generation skips edges

Part Number: MSPM0L1306
Other Parts Discussed in Thread: SYSCONFIG

Hello all,

my aim is to generate a PWM signal with a fixed on-time and a variable frequency of 300Hz to 400Hz that is updated every 1ms.

For that I set the "Load value" of the Timer to the corresponding timer value and the "capture compare value" of the off-time so that the on-time is always constant (~200us).

Parallelly, I have an 10us interrupt for ADC measurements.

Fullscreen
1
2
3
4
5
6
7
8
void Pwm_SetFrequencyTicks(uint16_t au16_Ticks)
{
/* Set the calculated Clock Timer Count for the PWM */
DL_Timer_setLoadValue(PWM_Transistor_Drive_INST, (uint16_t)(au16_Ticks - 1U));
/* Set the on time of the pwm */
DL_TimerG_setCaptureCompareValue(PWM_Transistor_Drive_INST, (au16_Ticks - PWM_ONTIME_TICKS), DL_TIMER_CC_1_INDEX);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Now, I have an issue where the PWM outputted by the controller randomly skips the falling edge of one PWM cycle every couple of seconds.

In a newer software version, I therefore inverted the PWM so that I can set the on-time of the PWM via the "capture compare value" directly and only once after startup.

With this change the issue seems to be resolved.

Fullscreen
1
2
3
4
5
void Pwm_SetFrequencyTicks(uint16_t au16_Ticks)
{
/* Set the calculated Clock Timer Count for the PWM */
DL_Timer_setLoadValue(PWM_Transistor_Drive_INST, (uint16_t)(au16_Ticks - 1U));
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

My question is: Is this a known problem or is my first implementation problematic? Can I be sure that my second implementation is really resolving the issue?

  • Hello Maximilian,

    What timer instance are you using?  For smooth transitions were you will be changing frequency/duty cycle, you will need to utilize TIMG4 instance that has the Shadow Load and Pipelined CC features. These features allow you to only load the changed value at the next load event (synchronous)  instead of immediately (asynchronous). Enabling Shadow Load allows you to change the frequency of the PWM smoothly, while the Pipeline CC enable will do the same for duty cycle. 

    Keep in mind, if you change the frequency of the PWM without changing the duty cycle, your relative duty cycle percentage ( and thus absolute time) will change. Now you can set it up where your min time of one side of the duty cycle (high or low, your choice) is always the same and the other side is variable. 

  • Hello Jace,

    thank you for your answer. Iam using TIMG4 as you can see in the attached sysconfig screeshot. Do I need to activate these features?

  • Maximillian,

    Control for these features in Sysconfig is not available yet, but that being said, most of it is enabled by default. The shadow load (freq) should be enabled by default. You can check by looking at the GCTL.SHDWLDEN bit in the device. This should be enabled by default, but you can make sure by utilizing DL_Timer_enableShadowFeatures() . Then you can just use the setLoadValue() you are today.  For the duty cycle value, you need to set the CC Update method using DL_Timer_setCaptCompUpdateMethod() to setup the pipeline CC feature.