drivers: pwm: pwm_stm32.c: enable ARR preload

Enable ARR preload so that period or pulse updates are taken
into account synchronously with update event
(at the end of a ongoing period)
And thus avoid undetermined intermediate pulse.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
This commit is contained in:
Alexandre Bourdiol 2020-10-28 17:50:33 +01:00 committed by Carles Cufí
commit c47a5d4a36

View file

@ -228,13 +228,17 @@ static int pwm_stm32_pin_set(const struct device *dev, uint32_t pwm,
return -EIO;
}
LL_TIM_EnableARRPreload(cfg->timer);
LL_TIM_OC_EnablePreload(cfg->timer, channel);
LL_TIM_SetAutoReload(cfg->timer, period_cycles - 1u);
LL_TIM_GenerateEvent_UPDATE(cfg->timer);
} else {
LL_TIM_OC_SetPolarity(cfg->timer, channel, get_polarity(flags));
set_timer_compare[pwm - 1u](cfg->timer, pulse_cycles);
LL_TIM_SetAutoReload(cfg->timer, period_cycles - 1u);
}
LL_TIM_SetAutoReload(cfg->timer, period_cycles - 1u);
return 0;
}