cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407VGT6 PWM Input mode and PWM Generation mode

TTú.1
Associate III

Hi everyone!

In my project, I use TIM2, TIM3, TIM4, TIM5, in each Timer module I choose PWM Input on CH1, and PWM Generation on CH3 function. My goal is to generate PWM pulse at channel 3 and feed back to PWM Input on CH1 to measure Duty cycle and frequency. For example, in the TIM2 module, I will connect the PWM Generation CH3 pin PB10 to the PWM Input on CH1 pin PA15. Other timer modules are similarly connected. But currently my program cannot measure Duty cycle and frequency. Is this method correct? Is it possible to use PWM Generation CHx and PWM Input on CHx function on the same Timer module?

I appreciate every answer.

This is my program

2 REPLIES 2
TDK
Guru

> Is it possible to use PWM Generation CHx and PWM Input on CHx function on the same Timer module?

Possibly, yes, but certainly not the typical method, and it has significant limitations. There's only one counter module for each timer. If you're using it for PWM generation, your update period is fixed. Using it for IC as well will be awkward. What's the point of measuring something you already know?

It is typically better to use a free-running timer to measure duty cycle/frequency. Subtract the tick times from successive triggers.

If you feel a post has answered your question, please click "Accept as Solution".
TTú.1
Associate III

Hi TDK

Thanks for your reply

I don't understand about > If you're using it for PWM generation, your update period is fixed.

Can you explain it?

I have a question: I am using PWM Input and PWM Generation function on same Timer, PWM Generation function work and PWM Input function don't work. Why doesn't it happen in the opposite direction?