atsam: Fix hard pwm cycle divider calculation

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-02-13 18:18:12 -05:00
parent a03e31809f
commit 0da65bf6b0
1 changed files with 1 additions and 1 deletions

View File

@ -71,7 +71,7 @@ gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val)
// Map cycle_time to pwm clock divisor // Map cycle_time to pwm clock divisor
uint32_t div; uint32_t div;
for (div=0; div<10; div++) for (div=0; div<10; div++)
if (cycle_time < (MAX_PWM << div) / 2) if (cycle_time < ((MAX_PWM << (div + 1)) + (MAX_PWM << div)) / 2)
break; break;
// Enable clock // Enable clock