From 05ce95645638c962a0d82fb8152d2819224a23af Mon Sep 17 00:00:00 2001 From: Timofey Titovets Date: Wed, 31 Dec 2025 12:39:02 +0100 Subject: [PATCH] stm32: fix static clock output for faster chips If pcycle_time is scaled, the value should be scaled as well Signed-off-by: Timofey Titovets --- src/stm32/hard_pwm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/stm32/hard_pwm.c b/src/stm32/hard_pwm.c index f4c8cdfde..d6ea6dfca 100644 --- a/src/stm32/hard_pwm.c +++ b/src/stm32/hard_pwm.c @@ -323,9 +323,11 @@ gpio_timer_setup(uint8_t pin, uint32_t cycle_time, uint32_t val, // CLK output if (is_clock_out) { prescaler = 1; + val = val / pclock_div; while (pcycle_time > UINT16_MAX) { prescaler = prescaler * 2; pcycle_time /= 2; + val /= 2; } max_pwm = pcycle_time; }