Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
habazut opened this issue Sep 28, 2022 · 4 comments · Fixed by #7346
Closed
1 task done
Assignees
Labels
Area: Peripherals API Relates to peripheral's APIs.
Milestone

Comments

@habazut
Copy link

habazut commented Sep 28, 2022

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.
@habazut habazut added the Status: Awaiting triage Issue is waiting for triage label Sep 28, 2022
@habazut
Copy link
Author

habazut commented Sep 28, 2022

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 added the Status: Needs investigation We need to do some research before taking next steps on this issue label Sep 29, 2022
@VojtechBartoska
Copy link
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
Copy link
Author

habazut commented Sep 29, 2022

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.

@VojtechBartoska VojtechBartoska added the Status: Community help needed Issue need help from any member from the Community. label Sep 29, 2022
@VojtechBartoska VojtechBartoska added Area: Peripherals API Relates to peripheral's APIs. and removed Status: Awaiting triage Issue is waiting for triage Status: Community help needed Issue need help from any member from the Community. labels Oct 10, 2022
@VojtechBartoska VojtechBartoska added this to the 2.0.6 milestone Oct 10, 2022
@P-R-O-C-H-Y
Copy link
Member

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

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);

@P-R-O-C-H-Y P-R-O-C-H-Y moved this from Todo to In Review in Arduino ESP32 Core Project Roadmap Oct 12, 2022
@P-R-O-C-H-Y P-R-O-C-H-Y moved this from In Review to In Progress in Arduino ESP32 Core Project Roadmap Oct 12, 2022
@P-R-O-C-H-Y P-R-O-C-H-Y removed the Status: Needs investigation We need to do some research before taking next steps on this issue label Oct 12, 2022
@P-R-O-C-H-Y P-R-O-C-H-Y moved this from In Progress to In Review in Arduino ESP32 Core Project Roadmap Oct 12, 2022
Repository owner moved this from In Review to Done in Arduino ESP32 Core Project Roadmap Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs.
Projects
Development

Successfully merging a pull request may close this issue.

3 participants