cancel
Showing results for 
Search instead for 
Did you mean: 

PWM generation

parag
Associate II
Posted on March 02, 2011 at 04:49

PWM generation

4 REPLIES 4
Posted on May 17, 2011 at 14:26

Please help why this is happening?

Perhaps your PCLK isn't what you think it is?  If you want people to analyze your code you need to post/attach complete working examples, especially when it has system level dependencies.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
parag
Associate II
Posted on May 17, 2011 at 14:26

Thanks a lot for reply Clive. Yes, you got it, i am not getting PCLK that i think. 

The thing is my project contain lots of other stuff that nothing do with PWM thats why i could not upload but copied the function that generate the PWM but i think code is working fine as i am getting output. I am feeling there is problem in ARR calculation or TIM3 clock that i consider but I am not sure. I have done like this

Prescaler = TIM3 clock/TIM3 counter clock - 1 // I have taken TIM3 clock = 36 Mhz is it true?

               = 36 MHz/36 MHz - 1  // as i want TIM3 counter clock   = 36 Mhz

               = 0

TIM3 Frequency = TIM3 counter clock/(ARR + 1)

           36 KHz = 36 MHz/(ARR+1)

           ARR = 999

so for 50% duty cycle CCR1 = 999 * 0.5 = 500

Is that calculation right for 36 KHz? 

Thanks for your time...

              

Posted on May 17, 2011 at 14:26

For a TIM3CLK of 36 MHz, output 36 KHz, 50/50 duty

Prescaler = 0; // x1

Period = 999; // 1000-1

Width = 500; // (Period + 1) / 2 = 50%

It is possible to make a stand-alone example that runs a few hundred lines, that just sets up TIM3

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mehmet.karakaya
Associate III
Posted on May 17, 2011 at 14:26

hello

did you started HSE at 72 MHz ?

maybe you still running at 8 MHz HSI