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.
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); }
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.
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));
}
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?