Difference between revisions of "STM32 Timer PWM Input Capture"
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
== Wiring == | == Wiring == | ||
+ | |||
+ | Since we are using the same board to generate and to decode the [[PWM]] signal, we need a jumper wire to connect the PWM Output to the PWM Input. The pinout resulting from the setup in the [[#STM32CubeMX Setup|next section]] looks like this: | ||
+ | |||
+ | [[File:PWM Input Capture example - pinout.png|600px]] | ||
+ | |||
+ | So, we will need to run | ||
== STM32CubeMX Setup == | == STM32CubeMX Setup == | ||
Line 18: | Line 24: | ||
[[File:PWM Input Capture example - Timer 2 confriguration.png|400px]] | [[File:PWM Input Capture example - Timer 2 confriguration.png|400px]] | ||
− | + | ||
== Miscellaneous Links == | == Miscellaneous Links == | ||
* [https://github.com/lbthomsen/blackpill/tree/master/pwm_ic PWM Input Capture Example] for [[Black Pill]] | * [https://github.com/lbthomsen/blackpill/tree/master/pwm_ic PWM Input Capture Example] for [[Black Pill]] |
Revision as of 04:04, 13 March 2022
The timers in STM32 MCUs are incredible powerful. We have used them before to generate PWM Signals and to decode signals from rotary encoders. In this example we will use them to determine frequency an duty cycle of an external PWM signal.
For the example we will be using a Black Pill development board and we will be using the same MCU to both generate and to decode the PWM signal.
The source of the complete example is here.
Wiring
Since we are using the same board to generate and to decode the PWM signal, we need a jumper wire to connect the PWM Output to the PWM Input. The pinout resulting from the setup in the next section looks like this:
So, we will need to run
STM32CubeMX Setup
Code