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