From acec9b9d35c86158f49d612fb79833936bfe6f9d Mon Sep 17 00:00:00 2001 From: qianyicheng Date: Fri, 21 Jul 2017 19:06:44 +0800 Subject: [PATCH] bugfix(ledc): fix integer divided by zero in function ledc_set_fade_with_time --- components/driver/ledc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/driver/ledc.c b/components/driver/ledc.c index 9cea7b5ec..559aad5fa 100644 --- a/components/driver/ledc.c +++ b/components/driver/ledc.c @@ -514,6 +514,9 @@ esp_err_t ledc_set_fade_with_time(ledc_mode_t speed_mode, ledc_channel_t channel return ESP_OK; } int total_cycles = max_fade_time_ms * freq / 1000; + if (total_cycles == 0) { + return ledc_set_duty(speed_mode, channel, target_duty); + } int scale, cycle_num; if (total_cycles > duty_delta) { scale = 1;