cancel
Showing results for 
Search instead for 
Did you mean: 

How to divide my Timer output?

Endika Caño de Miguel
Associate II
Posted on October 26, 2017 at 11:19

Hello:

I have set my TIM4 in PWM mode to get a 8MHz signal.

Now I need to get a 64KHz signal using the 8MHz signal, but I don�t know how to do it.

Also, I will have to change the Duty of the 64KHz signal.

Thank you in advance.

Endika

#stm32-l4 #nucleo #divide #pwm #timer #output
3 REPLIES 3
S.Ma
Principal
Posted on October 26, 2017 at 11:42

The question need more details. First, you take the period of the PWM. Say 64kHz.

Then you tell how many steps you want of duty cycle. If you want around 100 steps, the timer needs to count from 0 to 100 in 64kHz time period, so its counting frequency should be 64x100=64MHz or more. This 64 MHz must feed the timer clock and come from one of the clock sources of the timer (see the reference manual). Maybe you need to use the core at 128MHz and prescale the clock before feeding the timer clock. You could also inject a clock on the timer ETR or Channel 1 or 2 from another timer etc....

Omar BOUZOURRAA
Associate II
Posted on October 26, 2017 at 12:09

Hello

de_Miguel.Endika

,

I have a very simple way to do it I wrote an article about measuring high frequency signals with a good precision. To do that, I simply used a second Timer to divise the high frequency signal frequency, and then I used a third Timer to measure divided frequency (Divided frequency will be measured with a good precision) then I can compute the real frequency

Take a look at this article and don't hesitate to ask me for explanation ! Good Luck

🙂

https://www.linkedin.com/pulse/circumvent-hardware-limitation-microcontrollers-high-omar-bouzourraa/

Posted on October 26, 2017 at 12:02

Hello:

I´m pretty new using this kind of devices and I´m getting mad...

The thing is that I need both signals (8MHz and 64KHz) to be synchronized. So I´m trying to figure out how to set the clock source of the 

64KHz signal with the 8MHz one. 

I know how to generate both signals at the same time but when i look at the Osciloscope I can´t synchronize them