AnsweredAssumed Answered

Low freq PWM output

Question asked by wybranczyk.dominik on Nov 16, 2011
Latest reply on Dec 30, 2011 by M.E
Hello, 
I try the examples about PWM input form st.com, but it works only for big frequency signals. (like it is said in readme.txt). 
What should I change with settings TIM4 for example, to be able to check the low frequency signals on its CH2 input? By low freq I mean 50Hz.

I think about TIM_ICInitStructure.TIM_ICPrescaler coefficient. But form my calculations:
1st example - when Timer clock is 160 000 000 Hz :
Even if I chose TIM_ICPSC_DIV8 I get:
168 000 000 / 8 =  21 000 000
So If the input signal is like 50Hz that means :
21 000 000 / 50 = 420 000
So its approximately 430 000 clocks for 1 duty. While the TIM4 is 16-bit timer, so the max counter value is : 65 535. Its like 6 times overflow. 

2nd example - when my timer clock is 84 000 000:
TIM_ICPSC_DIV8 -> 84 000 000 / 8 = 10 500 000
So for 50 Hz its like:
10 500 000 / 50 = 210 000
Conclusion - there is 210 000 clock cycles for 1 duty of input PWM. The timer will overflow about 3 times.

It there any solution for this problem?
Should I change TIM_TimeBaseStructure for TIM4 before setting TIM_ICInitStructure ?
Or there is another way?

Outcomes