paparazzi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Paparazzi-devel] tim1 for servo pwm on stm32f4?


From: Chris
Subject: Re: [Paparazzi-devel] tim1 for servo pwm on stm32f4?
Date: Thu, 12 Sep 2013 13:45:08 +0300
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130803 Thunderbird/17.0.8

Hi Felix
I missed this line for stm32f10x:
"This section applies to XL-density devices only."
Anyway i am glad i can help.
Tomorrow i will try the adc which can use all 12 injected channels (3Adc x 4ch each)
for the stm32f4.
Chris


On 09/12/2013 12:07 PM, Felix Ruess wrote:
Hi Chris,

thanks!
Committed it with some indentation/cleanup and fixed it for the F1 again (clock source for TIM1, no TIM9 or TIM12).

So if you have more stuff, e.g. board file updates for the discovery.... now you know how it works ;-)

Cheers, Felix



On Wed, Sep 11, 2013 at 9:42 PM, Chris <address@hidden> wrote:
Hi Felix
I don't know if i succeeded because that was my first pull request. :-[
If you find the changes usefull i have more :-D
I have tested it with the stm32 discovery and it works fine in every combination i tried.
Chris


On 09/11/2013 09:38 PM, Felix Ruess wrote:
Hi Chris,

when you have it, a pull request to fix that would be very much appreciated!

Cheers, Felix


On Fri, Aug 30, 2013 at 12:45 PM, hendrixgr . <address@hidden> wrote:
Ok found it, it needed to configure the MOE bit in "break" register.
So far i have used all timers from TIM1 to TIM12 in any combination and it works fine he he he.
On to the "ppm_arc" and ADC  files now :-)
Chris
 


On Thu, Aug 29, 2013 at 5:10 PM, Felix Ruess <address@hidden> wrote:
Hi Chris,

true, the timer prescaler is not correct in all cases.
In ppm_arch.c this is properly taken into account, but in the pwm case we have to do that for each timer separately.
We should probably look at adding a convenience function to get the timer base freq to libopencm3.

Pull requests for this stuff welcome (I just quickly made the stm32f4_discovery file to test some basic stuff).

Cheers, Felix


On Thu, Aug 29, 2013 at 3:31 PM, Chris <address@hidden> wrote:
Hi Felix.
I edited the actuators_pwm_arch.c file so now i can use TIM9 & TIM12 for servo pwm and it works fine
(i tested it today on the discovery board)
but when i tried to use TIM1 making sure that no other peripheraL is using it, i get no output at all.
The reason i used TIM1 was because i can remap the OC pins at a higher port (port E) thus leaving me a lot of usefull pins free for other things.
I will search more this issue, i just wanted to let you know...
Also shouldn't the prescaler set to double the value as TIM1 uses APB2 which run at double speed?
 I think  " timer_set_prescaler(timer, (PCLK / ONE_MHZ_CLK) - 1); " should be
"timer_set_prescaler(timer, ((PCLK / ONE_MHZ_CLK)*2) - 1);" for timers that use the APB2 clock.
That is certainly true (as i found using an oscilloscope) for TIM9 as it also uses the APB2 clock.
Chris

Here is the relevant part of the board file:

// PWM
#define PWM_USE_TIM1 1
#define PWM_USE_TIM5 1
#define PWM_USE_TIM9 1

#define USE_PWM0 1
#define USE_PWM1 1
#define USE_PWM2 1
#define USE_PWM3 1
#define USE_PWM4 1
#define USE_PWM5 1
#define USE_PWM6 1
#define USE_PWM7 1
#define USE_PWM8 1
#define USE_PWM9 1

#define ACTUATORS_PWM_NB 10

// PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
#if USE_PWM0
#define PWM_SERVO_0 0
#define PWM_SERVO_0_TIMER TIM1
#define PWM_SERVO_0_RCC_IOP RCC_AHB1ENR_IOPEEN
#define PWM_SERVO_0_GPIO GPIOE
#define PWM_SERVO_0_PIN GPIO9
#define PWM_SERVO_0_AF GPIO_AF1
#define PWM_SERVO_0_OC TIM_OC1
#define PWM_SERVO_0_OC_BIT (1<<0)
#else
#define PWM_SERVO_0_OC_BIT 0
#endif

#if USE_PWM1
#define PWM_SERVO_1 1
#define PWM_SERVO_1_TIMER TIM1
#define PWM_SERVO_1_RCC_IOP RCC_AHB1ENR_IOPEEN
#define PWM_SERVO_1_GPIO GPIOE
#define PWM_SERVO_1_PIN GPIO11
#define PWM_SERVO_1_AF GPIO_AF1
#define PWM_SERVO_1_OC TIM_OC2
#define PWM_SERVO_1_OC_BIT (1<<1)
#else
#define PWM_SERVO_1_OC_BIT 0
#endif

#if USE_PWM2
#define PWM_SERVO_2 2
#define PWM_SERVO_2_TIMER TIM1
#define PWM_SERVO_2_RCC_IOP RCC_AHB1ENR_IOPEEN
#define PWM_SERVO_2_GPIO GPIOE
#define PWM_SERVO_2_PIN GPIO13
#define PWM_SERVO_2_AF GPIO_AF1
#define PWM_SERVO_2_OC TIM_OC3
#define PWM_SERVO_2_OC_BIT (1<<2)
#else
#define PWM_SERVO_2_OC_BIT 0
#endif

#if USE_PWM3
#define PWM_SERVO_3 3
#define PWM_SERVO_3_TIMER TIM1
#define PWM_SERVO_3_RCC_IOP RCC_AHB1ENR_IOPEEN
#define PWM_SERVO_3_GPIO GPIOE
#define PWM_SERVO_3_PIN GPIO14
#define PWM_SERVO_3_AF GPIO_AF1
#define PWM_SERVO_3_OC TIM_OC4
#define PWM_SERVO_3_OC_BIT (1<<3)
#else
#define PWM_SERVO_3_OC_BIT 0
#endif


_______________________________________________
Paparazzi-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/paparazzi-devel


_______________________________________________
Paparazzi-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/paparazzi-devel



_______________________________________________
Paparazzi-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/paparazzi-devel




_______________________________________________
Paparazzi-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/paparazzi-devel


_______________________________________________
Paparazzi-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/paparazzi-devel




_______________________________________________
Paparazzi-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/paparazzi-devel


reply via email to

[Prev in Thread] Current Thread [Next in Thread]