Skip to content

Commit 45e7296

Browse files
LaurentLoufCruz Monrreal II
authored andcommitted
Add some rounding to determine the pulse value for PWM for the STM target.
1 parent a4a00ff commit 45e7296

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

targets/TARGET_STM/pwmout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void pwmout_write(pwmout_t *obj, float value)
182182
value = 1.0;
183183
}
184184

185-
obj->pulse = (uint32_t)((float)obj->period * value);
185+
obj->pulse = (uint32_t)((float)obj->period * value + 0.5);
186186

187187
// Configure channels
188188
sConfig.OCMode = TIM_OCMODE_PWM1;

0 commit comments

Comments
 (0)