cancel
Showing results for 
Search instead for 
Did you mean: 

PWM with TIM1 lags

zexx86
Associate II
Posted on February 10, 2012 at 20:00

Hello

STM32RBT6 should control 1 servo with PWM output. For all TIM2 - TIM4 I tested it seems to be OK, but for TIM1 Channel 1 which is one I need it is working only occasionally what is very strange.

Sometime I just recompile same code and it is working correctly, until I recompile it again.

Well, it works, but output is very laggy - cca 1 second shoots.

It should control brushless regulator, it use same output as servos, so I testing it with some servos ..

Here is my code 

http://pastebin.com/hN2EsGH7

There are 2 servos, one with TIM2 which works smoothly as expected, second with TIM1. Notice, that it is controlled by same code.

I wonder TIM1 CH1 is used by something, but I can't find what, when throttle_init() is called right after RCC_APB2PeriphClockCmd() in main()..

Next thing, TIM1 CH1 servo don't react at all without TIM_CtrlPWMOutputs (TIM1, ENABLE);

Somebody know, where could be a problem ?

#tim1-channel-1-pwm
17 REPLIES 17
flyer31
Senior
Posted on February 12, 2012 at 01:46

You are sure that ST lib does not compile with optimization 0? I am using Keil 4.6.1 and I did not have any problems - I tried quite many of the timer/ PWM examples of the ST4 Discovery peripheral kit, I usually always used opt level 0 - no problems. Just I do not like these lib functions, because their init functions do complete initialisation only for the simpler timers. The more complex timers like TIM1 and TIM8 need some further initialisation, which is very well hidden, if you use the lib functions (it is not possible, to run e. g. a TIM3 PWM example by exchanging ''TIM3'' to ''TIM1'' - usually a lib should be made such, that this works) - so I prefer to set all bits myself - in this case at least I had to read through all the timer config bits once completely, so I have a better understanding of the particularities of each timer.

Posted on February 12, 2012 at 02:33

I am using Keil 4.6.1

Tomas is using GNU GCC, I'm using Keil V4.1.0.894 [Evaluation], from uVision 4.23
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
flyer31
Senior
Posted on February 12, 2012 at 05:44

Sorry for mixup - yes, my Keil version is the same as yours, Clive. Thanks for clarification.

zexx86
Associate II
Posted on February 12, 2012 at 08:27

I can compile std lib with 4.5.X at any optimization, but with 4.6.1 I am not able to compile it at all due to two lines of a assembly language.

Bill Lewis
Associate III
Posted on September 03, 2013 at 21:39

What is the difference between GPIO_PartialRemap_TIM3 and GPIO_FullRemap_TIM3 as used in the GPIO_PinRemapConfig() call?

Posted on September 03, 2013 at 22:46

What is the difference between GPIO_PartialRemap_TIM3 and GPIO_FullRemap_TIM3 as used in the GPIO_PinRemapConfig() call?

 

Two vs Four channels?

0690X000006050yQAA.png

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Bill Lewis
Associate III
Posted on September 03, 2013 at 23:46

Ahh!  I searched the forum and google'd but I never thought to look in the datasheet.  Doh!

Thank you, Clive!

If one uses Full remap but PC6 is not set to Alternate Function, will PC6 still function as a general purpose I/O pin?

Posted on September 04, 2013 at 02:40

Yes PC6 can remain as a GPIO, as can any channels you are not using, or ones which you are only using internally.

The F1 provides for peripheral/block remapping, the newer designs (L1, F2, F4) provide for a more flexible pin level remapping.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..