mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-02-09 01:31:19 -07:00
stm32: Fix off-by-one error in the prescaler calculation in hard_pwm.c
Some checks failed
Build test / build (push) Has been cancelled
Some checks failed
Build test / build (push) Has been cancelled
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
74a15f4834
commit
e60fe3d99b
1 changed files with 2 additions and 2 deletions
|
|
@ -11,7 +11,7 @@
|
|||
#include "internal.h" // GPIO
|
||||
#include "sched.h" // sched_shutdown
|
||||
|
||||
#define MAX_PWM (256 + 1)
|
||||
#define MAX_PWM 256
|
||||
DECL_CONSTANT("PWM_MAX", MAX_PWM);
|
||||
|
||||
struct gpio_pwm_info {
|
||||
|
|
@ -327,7 +327,7 @@ gpio_timer_setup(uint8_t pin, uint32_t cycle_time, uint32_t val,
|
|||
// In normal mode, allow the pulse frequency (cycle_time) to change
|
||||
// in order to maintain the requested duty ratio (val/MAX_PWM).
|
||||
hwpwm_ticks = MAX_PWM;
|
||||
prescaler = pcycle_time / (hwpwm_ticks - 1);
|
||||
prescaler = pcycle_time / MAX_PWM;
|
||||
if (prescaler > UINT16_MAX + 1)
|
||||
prescaler = UINT16_MAX + 1;
|
||||
else if (prescaler < 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue