[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Paparazzi-devel] tim1 for servo pwm on stm32f4?
From: |
Chris |
Subject: |
[Paparazzi-devel] tim1 for servo pwm on stm32f4? |
Date: |
Thu, 29 Aug 2013 16:31:56 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 |
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
- Re: [Paparazzi-devel] Xsens MTi-G, Iman, 2013/08/20
- Re: [Paparazzi-devel] Xsens MTi-G, Christophe De Wagter, 2013/08/20
- Re: [Paparazzi-devel] Xsens MTi-G, Iman, 2013/08/20
- Re: [Paparazzi-devel] Xsens MTi-G, Christophe De Wagter, 2013/08/22
- Re: [Paparazzi-devel] Xsens MTi-G, Christophe De Wagter, 2013/08/22
- Re: [Paparazzi-devel] Xsens MTi-G, Iman, 2013/08/22
- Re: [Paparazzi-devel] Xsens MTi-G, Iman, 2013/08/26
- Re: [Paparazzi-devel] Xsens MTi-G, Christophe De Wagter, 2013/08/26
- Re: [Paparazzi-devel] Xsens MTi-G, Iman, 2013/08/28
- Re: [Paparazzi-devel] Xsens MTi-G, Christophe De Wagter, 2013/08/29
- [Paparazzi-devel] tim1 for servo pwm on stm32f4?,
Chris <=
- Re: [Paparazzi-devel] tim1 for servo pwm on stm32f4?, Felix Ruess, 2013/08/29
- Re: [Paparazzi-devel] tim1 for servo pwm on stm32f4?, hendrixgr ., 2013/08/30