drivers: pwm: pwm_mcux_sctimer: duty cycle fix
This is a fix for a driver bug that assumes a user will want a new pwm channel for a new pwm signal if they decide to change the period length of the pwm. In some cases, this creates a noticable change of duty cycle accuracy. Signed-off-by: Emilio Benavente <emilio.benavente@nxp.com>
This commit is contained in:
parent
4156e10860
commit
5081f6aa28
|
@ -76,7 +76,8 @@ static int mcux_sctimer_pwm_set_cycles(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (period_cycles != data->period_cycles[channel]) {
|
||||
if (period_cycles != data->period_cycles[channel] &&
|
||||
duty_cycle != data->channel[channel].dutyCyclePercent) {
|
||||
uint32_t clock_freq;
|
||||
uint32_t pwm_freq;
|
||||
|
||||
|
@ -107,6 +108,7 @@ static int mcux_sctimer_pwm_set_cycles(const struct device *dev,
|
|||
|
||||
SCTIMER_StartTimer(config->base, kSCTIMER_Counter_U);
|
||||
} else {
|
||||
data->period_cycles[channel] = period_cycles;
|
||||
SCTIMER_UpdatePwmDutycycle(config->base, channel, duty_cycle,
|
||||
data->event_number[channel]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue