cancel
Showing results for 
Search instead for 
Did you mean: 

PWM Input Capture via CH3 and CH4

oli
Associate II
Posted on April 16, 2015 at 14:12

Hello

I want to measure the duty cycle of an input frequency on the stm32f4.

For that I need to use the TIM3 or TIM8 and there I have to use channel CH3 and CH4.

But now I'm looking for TIM_PWMIConfig(...) and there I just can configure CH1 and CH2. This is not what the manual RM0090 Shows.

Now my question is whether the channels CH3 and CH4 can even be used as PMW input capture to measure the duty cycle.

Thanks

Oliver

#stm32
6 REPLIES 6
Posted on April 16, 2015 at 15:00

You still can use Ch3/Ch4 to capture both edges of a single input, except that you can't use them as TRGI thus can't reset the counter upon one of the edges. This can be circumvented simply by subtracting the two captured value in software.

JW

Posted on April 16, 2015 at 17:20

Oliver,

Clive had answered this question recently, but the forum software doesn't support FAQs.

If you look at the block diagram for timer 1/8 or timer 2-5, upper right quadrant, there is a multiplexer with a bunch of inputs and two marked TI1FP1 and TI2FP2. These are the triggers that are used when resolving PWM inputs. When they change polarity, they will cause the counter blocks to load the counts and generate interrupts, that you use to feed your calculations.

TI1FP1 andTI2FP 2 come off of channels 1 and 2, respectively (bottom left quadrant). There is no TI3FP3 and 4, which would be the signals coming off of channels 3 and 4, so you can't use this method for PWM resolving. It's an unfortunate asymmetry.

So, you need to use channels 1 and 2 for PWM resolving, but this can also be done with timers 9-14 as well.
oli
Associate II
Posted on April 16, 2015 at 19:10

Thanks Jan for your reply.

But this means that I need even separate input pins for CH3 respectively for CH4 because the connection via TI3FP4 is absent?

Posted on April 16, 2015 at 19:26

No.

Look at the left-hand side of the diagram Andrei was referring to, to TI3FP4 and TI4FP3 signals. Read TIMx_CCMR2.CC3S/CC4S description.

As Andrei said above, the only difference to CH1/CH2 is that TI3FP3/TI4FP4 signals don't enter the TRGI multiplexor.

JW

oli
Associate II
Posted on April 16, 2015 at 19:28

Thanks Andrei for your reply,too.

It helped me for a better understanding of the module.

But I would like to ask one more question.

In your reply you describe the TI1FP1 / TI2FP2 which lead into the Encoder Interface and on the other side into the IC1 / IC2.

I guess there is no connection between the Encoder If and the ICx, isn't it?

What is the function of TI3FP3 / TI3FP4 respectively TI4FP4 / TI4FP3 for CH4 at the diagram?

Is it a bug at the manual?

oli
Associate II
Posted on April 16, 2015 at 19:37

Due to jan's reply this questions are obsolete.