mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #9105 from LaurentLouf/improve-precision-duty-cycle-pwm-stm
Add some rounding to determine the pulse value for PWM for the STM targetpull/9122/head
commit
ff6744c85e
|
@ -182,7 +182,7 @@ void pwmout_write(pwmout_t *obj, float value)
|
|||
value = 1.0;
|
||||
}
|
||||
|
||||
obj->pulse = (uint32_t)((float)obj->period * value);
|
||||
obj->pulse = (uint32_t)((float)obj->period * value + 0.5);
|
||||
|
||||
// Configure channels
|
||||
sConfig.OCMode = TIM_OCMODE_PWM1;
|
||||
|
|
Loading…
Reference in New Issue