Page 1 of 1

ledc not working

Posted: Fri Jun 19, 2020 8:58 pm
by michox
Hi everybody,
I have been trying to get a simple pwm signal running for half a day now and I have no clue why it is not working... The doc mentions that after ledc_channel_config the pwm signal should be generated... am I missing something? I am doing nothing else except this.
here is my code:

Code: Select all

ledc_timer_config_t ledc_timer = {
        .speed_mode = LEDC_LOW_SPEED_MODE,    // timer mode
        .duty_resolution = LEDC_TIMER_12_BIT, 
        .timer_num = LEDC_TIMER_1,            // timer index
        .freq_hz = 10,                         // frequency of PWM signal
    };
    ledc_timer_config(&ledc_timer);
    ledc_channel_config_t channel_config = {
        .gpio_num = 23,
        .speed_mode = LEDC_LOW_SPEED_MODE,
        .channel = LEDC_CHANNEL_0,
        .intr_type = LEDC_INTR_DISABLE,
        .timer_sel = LEDC_TIMER_1,
        .duty = 2048,
        .hpoint = 0,
    };
    ledc_channel_config(&channel_config);
    ledc_set_duty(channel_config.speed_mode, channel_config.channel, 2048);
    ledc_update_duty(channel_config.speed_mode, channel_config.channel);
Some tips would be greatly appreciated!

Re: ledc not working

Posted: Sat Jun 20, 2020 11:33 am
by ESP_Sprite
Can you check the return values of the ledc_* functions? They may be telling you what is wrong, and you're just throwing away that information. Also, is there any hint to what's wrong in the serial output of your program when it runs?

Re: ledc not working

Posted: Sun Jun 21, 2020 11:27 am
by michox
they were saying that all is fine (return code 0)
I got it to work by using the arduino framework functions

Code: Select all

    ledcAttachPin(MOTOR_STEP_PIN, LEDC_CHANNEL_0);
    ledcSetup(LEDC_CHANNEL_0, 0, LEDC_TIMER_12_BIT);
    ledcWrite(LEDC_CHANNEL_0, 2048);