Skip to content

LEDC pull request introduced regressions https://github.com/espressif/arduino-esp32/pull/6045 #7306

Closed
@habazut

Description

@habazut

Board

ESP32 Dev Module

Device Description

Dev board and LED

Hardware Configuration

GPIO connected to LED

Version

v2.0.4

IDE Name

Arduino IDE

Operating System

Linux

Flash frequency

Whatever

PSRAM enabled

no

Upload speed

115200

Description

The pull request #6045 introduced two regressions:

  1. It is not possible any more to do the following any more:

ledcSetup(...); ledcAttachPin(...); ledcWrite(...); // set up channel with freqency an duty cycle to blink LED
ledcDetachPin(...) // remove pin (LED OFF)
ledcAttachPin(...) // attach pin again and it continues with SAME frequency and duty as before

as ledcAttachPin nowadays resets the duty cycle of a prefectly working channel setup.

  1. ledcSetup(channel, 1, 8) can nor set up frequency of 1Hz any more

Harald.

Sketch

I think you understand anyway, see above.

Debug Message

00:49:16.724 -> E (247241) ledc: requested frequency and duty resolution can not be achieved, try reducing freq_hz or duty_resolution. div_param=8460032
00:49:16.758 -> [247245][E][esp32-hal-ledc.c:75] ledcSetup(): ledc setup failed!

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.

Activity

habazut

habazut commented on Sep 28, 2022

@habazut
Author

Suggestion how to fix ledcAttach:

void ledcAttachPin(uint8_t pin, uint8_t chan)
{
    if(chan >= LEDC_CHANNELS){
        return;
    }
    uint8_t group=(chan/8), channel=(chan%8);    
    ledc_set_pin(pin, group, channel);
}

Regards,
Harald.

VojtechBartoska

VojtechBartoska commented on Sep 29, 2022

@VojtechBartoska
Contributor

Hello @habazut, our Developer responsible for LedC is on vacation. He will take a look on this at mid of October. Thanks for understanding.

habazut

habazut commented on Sep 29, 2022

@habazut
Author

I have a workaround for the ledcAttach() issue (call ledc_set_pin direct) but not for the frequency issue of ledcSetup() for 1Hz. So if anyone has an idea how to get a LED to blink with PWM 1Hz, I would be grateful if you let me know.

Regards,
Harald.

added this to the 2.0.6 milestone on Oct 10, 2022
P-R-O-C-H-Y

P-R-O-C-H-Y commented on Oct 12, 2022

@P-R-O-C-H-Y
Member

Hello @habazut ,

  1. I am already working on a fix to keep the channels duty after pin attach. Will have PR ready today.
  2. About the 1Hz frequency. There is no issue for setting that, but you need to be careful what frequency and duty resolution you select. See ESP-IDF LEDC docs for more info -> link

Simple rule for using LEDC
lower frequencies -> higher resolution
higher frequencies -> lower resolution (example 40MHz freq can be set only with bit resolution 1)

I was able to set 1Hz frequency using 12 bits resolution ledcSetup(0,1,12);

6 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions

    LEDC pull request introduced regressions https://github.com/espressif/arduino-esp32/pull/6045 · Issue #7306 · espressif/arduino-esp32