BluePill PWM Generation Example Code Not Working #891
-
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
cc @rleh @chris-durand have more experience in this area of the HAL. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
The problem is that you can also use the timer channel in input capture mode and thus requires input. I think the solution is to document the Timer API properly, because there are a number of other pitfalls like forgetting to |
Beta Was this translation helpful? Give feedback.
-
ok! then for the time being I could just prepare a PWM modm example for the BluePill and adding a comment linking to this issue in the |
Beta Was this translation helpful? Give feedback.
-
Done! #897 |
Beta Was this translation helpful? Give feedback.
It was totally non-obvious for me at first but I think I have found it after digging through the reference manual and the modm GPIO source code. My first suspicion was right that this has to do with the odd F1 pin remapping design.
On all STM32 devices except F1 there is only one alternate function mode for both inputs and outputs. The pin direction is controlled by the peripheral.
On STM32F1 you have to manually select whether your alternate function pin is an input or output:
For input alternate functions standard input mode has to be selected.
In case of the timer the modm API has no way to tell which one you want by writing
Timer4::connect<GpioB7::Ch2>();
since the timer pin can be e…