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: Felix Ruess
Subject: Re: [Paparazzi-devel] tim1 for servo pwm on stm32f4?
Date: Wed, 11 Sep 2013 20:38:56 +0200

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



reply via email to

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