Skip to content

Commit 226e381

Browse files
marek14fabiobaltieri
authored andcommitted
drivers: pwm: pwm_stm32: Add error log for 16-bit timer buffer overflow
If the value in the period_cycles variable exceeds UINT16_MAX, a 16-bit timer will return an error code 134. An error message was added to indicate that the value does not fit into the 16-bit timer register. An error message advising developers to reduce the value to 16-bit simplifies the process, allowing them to understand immediately that reducing the value will resolve the issue. Signed-off-by: Marek Sroka <[email protected]>
1 parent 80a92f5 commit 226e381

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/pwm/pwm_stm32.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ static int pwm_stm32_set_cycles(const struct device *dev, uint32_t channel,
330330
*/
331331
if (!IS_TIM_32B_COUNTER_INSTANCE(cfg->timer) &&
332332
(period_cycles > UINT16_MAX + 1)) {
333+
LOG_ERR("Cannot set PWM output, value exceeds 16-bit timer limit.");
333334
return -ENOTSUP;
334335
}
335336

0 commit comments

Comments
 (0)