aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm32')
-rw-r--r--src/stm32/hard_pwm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/stm32/hard_pwm.c b/src/stm32/hard_pwm.c
index bbdd18b2..09a29ed5 100644
--- a/src/stm32/hard_pwm.c
+++ b/src/stm32/hard_pwm.c
@@ -291,10 +291,10 @@ gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val){
if (pclock_div > 1)
pclock_div /= 2; // Timers run at twice the normal pclock frequency
uint32_t prescaler = cycle_time / (pclock_div * (MAX_PWM - 1));
- if (prescaler > 0) {
- prescaler -= 1;
- } else if (prescaler > UINT16_MAX) {
+ if (prescaler > UINT16_MAX) {
prescaler = UINT16_MAX;
+ } else if (prescaler > 0) {
+ prescaler -= 1;
}
gpio_peripheral(p->pin, p->function, 0);