cancel
Showing results for 
Search instead for 
Did you mean: 

STM32429I-EVAL1 - PWM with different freq from same Timer

arturdav87
Associate II
Posted on December 26, 2014 at 15:14

hey,

I would like to know if I can use with different channels of the same TIM and get different freq for each channel (i am NOT talking about Duty Cycle).

if there is an options, how i config this parameter? 

#pwm
6 REPLIES 6
uc2013135191
Associate II
Posted on December 26, 2014 at 15:54

Hi david,

You have 17 different timers = 17 different frequencies! 

Never seen a timer capable of 2 difference frequencies output in each channel and i didn't see any indication this MCU has timers capable of doing that.

Posted on December 26, 2014 at 16:40

No, each timer has a SINGLE counting element, and this would define the period.

Now one can generate multiple frequencies if they baby sit the timer in maximal mode, and advance the compare (CCRx) points under interrupt, and toggle or act on those.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arturdav87
Associate II
Posted on December 26, 2014 at 21:55

thanks for your ans,

clive1 - you mean Auto-Reload register?  i know from-  Figure 86. Advanced-control timer block diagram that only  Auto-Reload register is can changed by Interrupt.

and the formula is:   freq = Counter Clock(21MHZ)  / Auto-Reload register.

so you mean to change this by interrupt and each time turn on/off  relevant TIMx_Channel ?

or maybe you can give me an example?

Thanks a lot.

Posted on December 26, 2014 at 22:35

No, I mean the ARR (Period) is 0xFFFF or 0xFFFFFFFF for 16-bit or 32-bit timers respectively, and you advance the CCRx compare registers

ie

On CC1

TIM2->CCR1 += 1000;

On CC2

TIM2->CCR2 += 2000;

\STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Examples\TIM\TIM_OCToggle

\STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Examples\TIM\TIM_TIM9OCToggle

\STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Examples\TIM\TIM_TimeBase
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arturdav87
Associate II
Posted on December 28, 2014 at 20:22

So, I tried all examples but its not what I was looking - I need to get from one Timer 2 different Freq + modify PWM D.C.

From this examples I see that if you choose different freq, you cannot change the D.C (fixed to 50%).

there is an option to get 20KHz and 200Hz  + PWM   from one timer?   

Posted on December 29, 2014 at 00:02

From this examples I see that if you choose different freq, you cannot change the D.C (fixed to 50%).

But think about this for a second, you control the placement of both edges, you can modulate the signal anyway you want.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..