while tracking down another bug concerning single inverted ports between an old compiled image and a brand new one, I stumbled across this. Maybe (hopefully?) this is extremely simple, but the subroutine version worked with the old image (compiled using esp32 v1.9.x in Arduino 1.8.13), while the current 2.0.2 in 1.8.19 throws me this error:
- 22:31:49.793 -> a
- 22:31:49.793 -> E (1099) ledc: requested frequency and duty resolution can not be achieved, try reducing freq_hz or duty_resolution. div_param=0
- 22:31:49.793 -> b
ESP-WROOM32 on a random AliExpress dev board.
Working code for 2.x:
- #include <driver/ledc.h>
- void setup()
- {
- Serial.begin(115200);
- delay(1000); // give me time to bring up serial monitor
- ledc_timer_config_t ledc_timer;
- ledc_timer.speed_mode = LEDC_HIGH_SPEED_MODE;
- ledc_timer.timer_num = LEDC_TIMER_1;
- ledc_timer.duty_resolution = LEDC_TIMER_8_BIT;
- ledc_timer.freq_hz = 5000;
- ledc_channel_config_t ledc_channel0;
- ledc_channel0.channel = LEDC_CHANNEL_0;
- ledc_channel0.gpio_num = 2;
- ledc_channel0.speed_mode = LEDC_HIGH_SPEED_MODE;
- ledc_channel0.intr_type = LEDC_INTR_FADE_END;
- ledc_channel0.timer_sel = LEDC_TIMER_1;
- ledc_channel0.hpoint = 0;
- ledc_channel0.duty = 255;
- Serial.println("a");
- ledc_timer_config(&ledc_timer);
- Serial.println("b");
- ledc_channel_config(&ledc_channel0); //onboard
- ledc_fade_func_install(ESP_INTR_FLAG_SHARED);
- }
- void loop(){}
- #include <driver/ledc.h>
- void setup()
- {
- Serial.begin(115200);
- delay(1000); // give me time to bring up serial monitor
- setupLEDs();
- }
- void setupLEDs() {
- ledc_timer_config_t ledc_timer;
- ledc_timer.speed_mode = LEDC_HIGH_SPEED_MODE;
- ledc_timer.timer_num = LEDC_TIMER_1;
- ledc_timer.duty_resolution = LEDC_TIMER_8_BIT;
- ledc_timer.freq_hz = 5000;
- ledc_channel_config_t ledc_channel0;
- ledc_channel0.channel = LEDC_CHANNEL_0;
- ledc_channel0.gpio_num = 2;
- ledc_channel0.speed_mode = LEDC_HIGH_SPEED_MODE;
- ledc_channel0.intr_type = LEDC_INTR_FADE_END;
- ledc_channel0.timer_sel = LEDC_TIMER_1;
- ledc_channel0.hpoint = 0;
- ledc_channel0.duty = 255;
- Serial.println("a");
- ledc_timer_config(&ledc_timer);
- Serial.println("b");
- ledc_channel_config(&ledc_channel0); //onboard
- ledc_fade_func_install(ESP_INTR_FLAG_SHARED);
- }
- void loop(){}