From 5e47ffdaf9783d58bb1c9cdfa83eaa90cd7d2b78 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Mon, 25 Jan 2016 12:51:32 -1000 Subject: [PATCH] Moved Switching IO to the point of ARMing --- src/drivers/stm32/drv_pwm_servo.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/drivers/stm32/drv_pwm_servo.c b/src/drivers/stm32/drv_pwm_servo.c index 3a24f19922..89f67e0503 100644 --- a/src/drivers/stm32/drv_pwm_servo.c +++ b/src/drivers/stm32/drv_pwm_servo.c @@ -140,9 +140,6 @@ pwm_channel_init(unsigned channel) { unsigned timer = pwm_channels[channel].timer_index; - /* configure the GPIO first */ - stm32_configgpio(pwm_channels[channel].gpio); - /* configure the channel */ switch (pwm_channels[channel].timer_channel) { case 1: @@ -333,9 +330,16 @@ up_pwm_servo_arm(bool armed) for (unsigned i = 0; i < PWM_SERVO_MAX_TIMERS; i++) { if (pwm_timers[i].base != 0) { if (armed) { + /* force an update to preload all registers */ rEGR(i) = GTIM_EGR_UG; + for (unsigned c = 0; c < PWM_SERVO_MAX_CHANNELS; c++) { + if (pwm_channels[c].gpio) { + stm32_configgpio(pwm_channels[c].gpio); + } + } + /* arm requires the timer be enabled */ rCR1(i) |= GTIM_CR1_CEN | GTIM_CR1_ARPE;