RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

stm32f4: pwm_init returns wrong value

Open A-Paul opened this issue 10 years ago • 5 comments

In cpu/stm32f4/periph/pwm.c pwm_init is returning the requested input value. It should return a frequency that is calculated based on actual clock and prescaler values.

A-Paul avatar Dec 08 '15 15:12 A-Paul

not sure, but isn't the implementation actually correct? As the STM32F4 has very fine means for defining the actual clock, I think the configured value is the same (or at leas very very close) to the requested value.

haukepetersen avatar Dec 08 '15 16:12 haukepetersen

but then again - I implemented it and thought this then also, I might be wrong here... Do you maybe have an example where the returned value differs from the value set?

haukepetersen avatar Dec 08 '15 16:12 haukepetersen

defining the actual clock, I think the configured value is the same (or at leas very very close) to the requested value.

This is integer division. They can't be the same. Except in special cases, when res * freq is a divisor of the clock frequency. The differences are growing with the value of that product.

A-Paul avatar Dec 08 '15 17:12 A-Paul

Ok, forgot what I wrote above, I had some twists in my thoughts, you are completely right!

haukepetersen avatar Dec 09 '15 14:12 haukepetersen

how about this fix? #4454

haukepetersen avatar Dec 09 '15 14:12 haukepetersen