From f89af39654dffae17548973286c12b82466c49eb Mon Sep 17 00:00:00 2001 From: Francisco Gil Date: Thu, 30 Nov 2017 10:43:48 +0100 Subject: [PATCH] pwm: fix a problem with the pwm example. The first time that the example is run there was an error related with an invalid value for the duty cycle. With this fix we set the duty cycle to 0 when we close the example. Signed-off-by: Francisco Gil --- apix-pwm-example/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apix-pwm-example/main.c b/apix-pwm-example/main.c index ef50bc6..e3eacdc 100644 --- a/apix-pwm-example/main.c +++ b/apix-pwm-example/main.c @@ -64,6 +64,7 @@ static void cleanup(void) { running = 0; if (pwm_line) { + ldx_pwm_set_duty_cycle(pwm_line, 0); ldx_pwm_enable(pwm_line, PWM_DISABLED); ldx_pwm_free(pwm_line); } @@ -171,8 +172,6 @@ int main(int argc, char **argv) register_signals(); printf("Setting PWM frequency to %dHz...", pwm_freq); - /* Set a duty cycle of 0 to avoid errors configuring the frequency */ - ldx_pwm_set_duty_cycle(pwm_line, 0); ret = ldx_pwm_set_freq(pwm_line, pwm_freq); if (ret != PWM_CONFIG_ERROR_NONE) { printf("Failed\n");