From a11b839dd58ab96f77bdddbcc634b14b1c89e8dd Mon Sep 17 00:00:00 2001 From: Martin Guy Date: Wed, 5 Oct 2011 02:44:47 +0200 Subject: [PATCH] Respect the User's Guide by disabling a PWM channel before changing its params It seemed to work just to change the PWM frequency and duty cycle on the fly but the User's Guid says to disable itberfore doing this. So we do. --- src/platform/avr32/pwm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/platform/avr32/pwm.c b/src/platform/avr32/pwm.c index 88e43bbf..000ccd1a 100644 --- a/src/platform/avr32/pwm.c +++ b/src/platform/avr32/pwm.c @@ -208,16 +208,14 @@ void pwm_channel_set_period_and_duty_cycle( unsigned id, u32 period, u32 duty ) } } #else - // No nasty interrupts: just disable, configure and re-enable. - // In practice, it seems you don't even need to disable the channel - // like the User's Guide tells you to, so we don't bother. + // No nasty asynchronous stuff. just disable, configure and re-enable. { - //int was_enabled = AVR32_PWM.sr & (1 << id); + int was_enabled = AVR32_PWM.sr & (1 << id); - //if (was_enabled) AVR32_PWM.dis = 1 << id; + if (was_enabled) AVR32_PWM.dis = 1 << id; AVR32_PWM.channel[id].cprd = period; AVR32_PWM.channel[id].cdty = duty; - //if (was_enabled) AVR32_PWM.ena = 1 << id; + if (was_enabled) AVR32_PWM.ena = 1 << id; } #endif }