Skip to content

LEDC resolution issue #11164

Closed
Closed
@Vladislav-Jovanov

Description

@Vladislav-Jovanov

Board

ESP32 Dev Board

Device Description

Terminal adapter

Hardware Configuration

GPIO 5,2,14 were tested out

Version

latest master (checkout manually)

IDE Name

Arduion IDE

Operating System

Linux Mint

Flash frequency

40 MHz

PSRAM enabled

yes

Upload speed

115200

Description

I am not sure if this is a software or hardware issue.
I was testing out different combinations of frequency and ledc resolution and duty cycle. I wanted to set resolution to LEDC_TIMER_1_BIT and duty to 1 (50%) and then to vary frequency from really low (few Hz to MHz).

What I noticed was that combination LEDC_TIMER_1_BIT and duty of 1 does not work for low frequencies below 489 Hz. I don't understand why. Is that a software or hardware issue? In technical documentation there is no information about this. An answer to this issue would be sufficient.

Sketch

#include "driver/ledc.h"

#if defined (ESP32)
    #define LEDC_TIMER              LEDC_TIMER_0
    #define LEDC_MODE               LEDC_HIGH_SPEED_MODE
    #define LEDC_CHANNEL            LEDC_CHANNEL_0
    #define LEDC_DUTY_RES           LEDC_TIMER_1_BIT // Set duty resolution to 13 bits
    #define LEDC_DUTY               1 // Set duty to 50%. (2 ** 8) * 50% = 4096
    #define LEDC_FREQUENCY          1 // Frequency in Hertz. Set frequency at 4 kHz
#endif

#define LED_GPIO 5

void setup() {
  #if defined (ESP32)
        ledc_timer_config_t ledc_timer = {
            .speed_mode       = LEDC_MODE,
            .duty_resolution  = LEDC_DUTY_RES,
            .timer_num        = LEDC_TIMER,
            .freq_hz          = LEDC_FREQUENCY,  // Set output frequency at 5 kHz
            .clk_cfg          = LEDC_AUTO_CLK
        };

        ledc_channel_config_t ledc_channel = {
            .gpio_num       = LED_GPIO,
            .speed_mode     = LEDC_MODE,
            .channel        = LEDC_CHANNEL,
            .intr_type      = LEDC_INTR_DISABLE,
            .timer_sel      = LEDC_TIMER,
            .duty           = LEDC_DUTY, // Set duty to 0%
            .hpoint         = 0 //phase shift
        };
        ledc_timer_config(&ledc_timer);
        ledc_channel_config(&ledc_channel);
    #endif
}

void loop() {

}

Debug Message

No message.

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions