From 226e381d6e9631b2c425ee0ff5493abcc93daf83 Mon Sep 17 00:00:00 2001 From: Marek Sroka Date: Wed, 14 Aug 2024 15:27:51 +0200 Subject: [PATCH] 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 --- drivers/pwm/pwm_stm32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pwm/pwm_stm32.c b/drivers/pwm/pwm_stm32.c index 70006e377b1..82224d1961f 100644 --- a/drivers/pwm/pwm_stm32.c +++ b/drivers/pwm/pwm_stm32.c @@ -330,6 +330,7 @@ static int pwm_stm32_set_cycles(const struct device *dev, uint32_t channel, */ if (!IS_TIM_32B_COUNTER_INSTANCE(cfg->timer) && (period_cycles > UINT16_MAX + 1)) { + LOG_ERR("Cannot set PWM output, value exceeds 16-bit timer limit."); return -ENOTSUP; }