LEDC Fade
Posted: Thu Oct 08, 2020 12:32 pm
Hello guys,
I don't understand the functionality of the LEDC Fade.
I would like to illustrate my problems with following example project. I took the ledc example project and only did few adjustments and then the LEDs do something garbage:
I changed the GPIO Pins to PIN 18,19,23,33 and changed the while loop. All the other stuff stay the same.
The while loop is the following:
So as you can see I only comment out a few lines.
The result looks like:
Now 1 LED is always on and the other 3 are fading. Why there is 1 LED always on an why there is the warning message "ledc: LEDC FADE TOO SLOW"?
Thank you
I don't understand the functionality of the LEDC Fade.
I would like to illustrate my problems with following example project. I took the ledc example project and only did few adjustments and then the LEDs do something garbage:
I changed the GPIO Pins to PIN 18,19,23,33 and changed the while loop. All the other stuff stay the same.
The while loop is the following:
Code: Select all
while (1) {
printf("1. LEDC fade up to duty = %d\n", LEDC_TEST_DUTY);
for (ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
ledc_set_fade_with_time(ledc_channel[ch].speed_mode,
ledc_channel[ch].channel, LEDC_TEST_DUTY, LEDC_TEST_FADE_TIME);
ledc_fade_start(ledc_channel[ch].speed_mode,
ledc_channel[ch].channel, LEDC_FADE_NO_WAIT);
}
// 1. adjustment: comment out the vTaskDelay
//vTaskDelay(LEDC_TEST_FADE_TIME / portTICK_PERIOD_MS);
printf("2. LEDC fade down to duty = 0\n");
for (ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
ledc_set_fade_with_time(ledc_channel[ch].speed_mode,
ledc_channel[ch].channel, 0, LEDC_TEST_FADE_TIME);
ledc_fade_start(ledc_channel[ch].speed_mode,
ledc_channel[ch].channel, LEDC_FADE_NO_WAIT);
}
vTaskDelay(LEDC_TEST_FADE_TIME / portTICK_PERIOD_MS);
printf("3. LEDC set duty = %d without fade\n", LEDC_TEST_DUTY);
for (ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
ledc_set_duty(ledc_channel[ch].speed_mode, ledc_channel[ch].channel, LEDC_TEST_DUTY);
ledc_update_duty(ledc_channel[ch].speed_mode, ledc_channel[ch].channel);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
// 2. adjustment: comment out the following for loop
/*
printf("4. LEDC set duty = 0 without fade\n");
for (ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
ledc_set_duty(ledc_channel[ch].speed_mode, ledc_channel[ch].channel, 0);
ledc_update_duty(ledc_channel[ch].speed_mode, ledc_channel[ch].channel);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);*/
}
The result looks like:
Code: Select all
I (311) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
1. LEDC fade up to duty = 4000
2. LEDC fade down to duty = 0
W (337) ledc: LEDC FADE TOO SLOW
W (337) ledc: LEDC FADE TOO SLOW
3. LEDC set duty = 4000 without fade
1. LEDC fade up to duty = 4000
2. LEDC fade down to duty = 0
W (4337) ledc: LEDC FADE TOO SLOW
3. LEDC set duty = 4000 without fade
1. LEDC fade up to duty = 4000
2. LEDC fade down to duty = 0
3. LEDC set duty = 4000 without fade
Thank you