Skip to content
Snippets Groups Projects
Commit 04110fbd authored by Peter Kietzmann's avatar Peter Kietzmann
Browse files

Merge pull request #3405 from A-Paul/fix_stm32f3_pwm_driver

cpu/stm32f3: PWM driver, some corrections.
parents 935e2d81 82c16f2b
No related branches found
No related tags found
No related merge requests found
......@@ -98,7 +98,8 @@ int pwm_init(pwm_t dev, pwm_mode_t mode, unsigned int frequency, unsigned int re
return -2;
}
tim->PSC = (pwm_clk / (resolution * frequency)) - 1;
tim->ARR = resolution;
tim->ARR = resolution - 1;
frequency = (pwm_clk / (resolution * (tim->PSC + 1)));
/* set PWM mode */
switch (mode) {
......@@ -147,7 +148,9 @@ int pwm_set(pwm_t dev, int channel, unsigned int value)
return -1;
}
/* norm value to maximum possible value */
/* norm value to maximum possible value
* Caution! A duty cycle exceeding the period length can lead to unexpected
* behaviour on other MCUs. */
if (value > 0xffff) {
value = 0xffff;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment