I am trying to set up PWM input on the STM32F302R8 to calculate frequency and duty cycle. In the STM32F302x8 reference manual, it says that we need to map IC1
to TI1
(CC1S
= 01) and to map IC2
to TI1
.
To match what the STM32F302x8 reference manual suggests, I need IC Selection
to be Direct
for Channel 1 and Indirect
for Channel 2. I hardcoded the settings and the PWM inputs worked.
I wanted to set this up in CubeMX, but it only allows IC Selection
= Direct
. And having both channels as Direct
does not work because the counter of IC channel 1 always returns 0.
What am I doing wrong here? I am unsure how to set up PWM input correctly in STM32CubeMX.
Wow, that seems to be it. I really got confused with CubeMX's UI. Do you also happen to know the difference between using direct on both channels, versus using direct on one channel and indirect on the other? I have seen examples with both configurations.
In that case IC2 is connected to the physical TIMx_CH2 pin. I guess it's still possible to measure a PWM signal in that configuration, but you need to connect the same signal to 2 physical pins (and this doesn't make much sense). Of course, that configuration can be useful to detect periods (but not duty cycles) of 2 separate signals.
You're talking about the configuration in which both channels are "direct"?
For example, if both IC1 & IC2 are direct, it means that IC1 is connected to TIMx_CH1 pin and IC2 is connected to TIMx_CH2 pin.
Awesome, I think this is making more sense to me now. However, when I map IC1 and IC2 both to TI1, what is that actually doing? Does it mean I'm connecting TIMx_CH1 to both IC1 and IC2? What does TI1 represent?