Skip to main content
zexx86
Associate III
February 10, 2012
Question

PWM with TIM1 lags

  • February 10, 2012
  • 17 replies
  • 2070 views
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
This topic has been closed for replies.

17 replies

Tesla DeLorean
Guru
February 12, 2012
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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
flyer31
Senior
February 12, 2012
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
zexx86Author
Associate III
February 12, 2012
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
September 3, 2013
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?

Tesla DeLorean
Guru
September 3, 2013
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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Bill Lewis
Associate III
September 3, 2013
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?

Tesla DeLorean
Guru
September 4, 2013
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 (See Profile) Up vote any posts that you find helpful, it shows what's working..